I need to make a script that, when one button is pressed, will press the combination of keys and "holds" it (keeps it pressed), until i release the button
-Why i need this
i have an extention floating window, which appears only when i keep pressed combination ctrl+H (i press it and hold), and when i release this combination - window dissapears.
-My trials and errors
i'm really a stranger to luamacro and using it only to program macros for photoshop, so only possible way for me to create macro - is to compilate one from ready solutions, but this one is too complex for me to handle by this way. I've tried to rewrite standart example coming with luamacro, but i think i'm just doing dumb stuff. If you can help me with pure solution i'll be really thankful, but still, i'll attach my really stupid script, maybe it'll be helpful
Code: Select all
-- choose keyboard for macros, assign logical name
lmc_assign_keyboard('MACROS');
-- send any key (letter) as keystroke
function press(key)
lmc_send_input(string.byte(key), 0, 0) -- press
lmc_send_input(string.byte(key), 0, 2) -- release
end
-- wraps function call with ctrl press
function withCTRL(callback)
lmc_send_input(17, 0, 0) -- press
callback()
lmc_send_input(17, 0, 2) -- release
end
-- define callback for 'A' key
lmc_set_handler('MACROS',65,0,function(button, direction)
withCTRL(function() press('H') end)
end)
Code: Select all
lmc_set_handler('MACROS',65,0,function(button, direction)
Code: Select all
lmc_set_handler('MACROS',65,2,function(button, direction)
I cannot simulate the press and hold for the "ctrl+h" key combination, needed for this window to be used
Please, can you help me to create script that can simulate press and hold behaviour for this combination of keys?
i can simulate this behavior for one button using
Code: Select all
lmc_set_handler('MACROS1',function(button, direction)
if (button == string.byte('D')) then -- if m
if (direction == 1) then lmc_send_input(16, 0, 0) -- press shift
elseif (direction == 0) then lmc_send_input(16, 0, 2) -- release shift
end
but i can't understand how to do this for the combination like ctrl+h
also i can use ahk, and it works, but i don't know how to separate this script only for my second hid keyboard and i think it will be much more comfortable just to use only luamacros.
Thanks