Basically want to make a macro script

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Nov 13 15:29:45 PST 2014


I just reorganized the code adding that stuff to simpledisplay.d. 
I think you should still understand the implementation code so 
you can customize it, but the main thing should look simpler now:

// same command to compile as before:
// dmd hotkey.d simpledisplay.d color.d -L/SUBSYSTEM:WINDOWS:5.0

void main() {
	import core.sys.windows.windows;
	import simpledisplay;

	auto window = new SimpleWindow(100, 50, "Hotkey");

	window.registerHotKey(0, VK_F2, {
		sendSyntheticInput("Hello");
	});
	window.registerHotKey(0, VK_F4, {
		sendSyntheticInput(", world!\n");
	});

	window.eventLoop(0);
}

Update simpledisplay.d by downloading the new file from github
https://github.com/adamdruppe/arsd/blob/master/simpledisplay.d


The new function works the same way as the old: modifiers, then 
virtual key code. The difference is the handler is put on the 
same line (I also renamed sendString to sendSyntheticInput to fit 
in simpledisplay.d).


Heck, I could even make this an exe with a little text area 
inside the window to set the listener script and a GUI to select 
the keys if I spent another hour or two on it...

but meh, see how far you can get now, playing with it a while 
will help you learn too.


More information about the Digitalmars-d-learn mailing list