Closed markozivkovich closed 5 years ago
If you are using one keyboard only, maybe AutoHotKey is easier to work with?
No sir, ahk even if it's running in background many games do not allow it, can't risk the ban. My upper written code is working, but i just don't know how to execute it with single button
Yes, you can define handler (callback function) only for one key (left ctrl) and other's won't be affected. You need to add additional parameters to lmc_set_handler. See https://github.com/me2d13/luamacros/wiki/Triggers#specific-key
I have read it, but when example -
In first case: I define handler
lmc_set_handler('lul',76,1,function(button,direction) if ( direction == 1) then lmc_send_input(65, 0, 0) lmc_send_input(65, 0, 2) elseif (direction == 0) then lmc_send_input(80, 0, 0) lmc_send_input(80, 0, 2) end end )
like this only executes the first part or " if ( direction == 1) then" part of function
In first case: I define handler
lmc_set_handler('lul',76,0,function(button,direction) if ( direction == 1) then lmc_send_input(65, 0, 0) lmc_send_input(65, 0, 2) elseif (direction == 0) then lmc_send_input(80, 0, 0) lmc_send_input(80, 0, 2) end end )
And like this only executes the second part or " elseif (direction == 0) then" part of function
How to do it both?
Set 2 handlers and you don't need the if for direction in callback function. You can call lmc_set_handler any times you want with different parameters. So something like:
lmc_set_handler('lul',76,1,function(button) lmc_send_input(65, 0, 0) lmc_send_input(65, 0, 2) end )
lmc_set_handler('lul',76,0,function(button) lmc_send_input(80, 0, 0) lmc_send_input(80, 0, 2) end )
Thank you very much now that is it.
Hello Petr, I need help with LuaMacros. Is there any chance when I execute my code:
lmc_device_set_name('lul','1549AFE2') lmc_print_devices()
lmc_set_handler('lul', function(button,direction) if ( direction == 1) then lmc_send_input(17, 0, 0) elseif (direction == 0) then lmc_send_input(17, 0, 2) lmc_send_input(17, 0, 0) lmc_send_input(17, 0, 2) end end )
To work only when i press left ctrl, and all other keys to work properly, I have only one keyboard.