So here we go.
Download LuaMacros zip file, extract to any folder on your disc. There's no installation needed to run LuaMacros, but you need to have all files extracted. Start luamacros.exe and paste this script into editor:
Code: Select all
-- assign logical name to macro keyboard
lmc_assign_keyboard('MACROS');
-- define callback for whole device
lmc_set_handler('MACROS',function(button, direction)
if (direction == 1) then return end -- ignore down
if (button == string.byte('C')) then lmc_spawn("calc")
elseif (button == string.byte('N')) then lmc_spawn("notepad", "C:\\test.txt")
elseif (button == string.byte('H')) then lmc_send_keys('Hello world')
else print('Not yet assigned: ' .. button)
end
end)
Purpose of this script is to define one keyboard as "macro" keyboard and assign some function to 3 keys on this keyboard.
So once you start the script LuaMacros will ask you to identify the macros keyboard by pressing any button on this keyboard. This is what command lmc_assign_keyboard does.
Once you press any key at the keyboard the keyboard will be "hooked" to trigger macros and won't work as usual (keys pressed on this keyboard won't reach active application - e.g. you can not type in Notepad with this keyboard). Other keyboards will work.
Now if you press C on this macro keyboard, windows calculator will start. If you press N notepad will start and will open file test.txt from C:\. This is done just to demonstrate command line arguments - the file usually won't exist so Notepad will ask you if this is new file and should be created.
Finally if you press H the active application (maybe that Notepad) will receive "Hello world" keystrokes.
Any other key from macro keyboard won't do anything, just info message will be logged.