There is a way, with a couple caveats.
First of all, from what I've heard autohotkey is just the right sort of tool for this job, although I have never used it myself. You might check it out. Don't get me wrong, LuaMacros can do it too, but it might be overkill.
The other consideration is that this may not work 100%, for the simple reason that while we can send keydown and keyup events, the programme might still find out that the key isn't actually being held down (for example, if at any point it checks the key state of F24, it might see through your ruse).
What you're going to want to do is to start the programme in LuaMacros with the -k parameter (which prevents it from locking up your keyboard). I would advise that you simply create a shortcut which you put in your Startup folder so that it runs automatically when you boot your computer. Create a shortcut to LuaMacros.exe, and then open its properties and under target put:
"C:\path to LuaMacros\LuaMacros.exe" -k -r "C:\path to programme\PTTHotkey.lua"
The -k prevents it from blocking your keystrokes, and the -r parameter runs the programme specified.
Here's the code for the programme (I assumed above it was saved to "C:\path to programme\PTTHotkey.lua"):
Code: Select all
--Set LUAMacros to minimise to tray, then minimise- this is to hide it.
lmc.minimizeToTray = true
lmc_minimize()
--Set the name Keyboard to your keyboard, using a unique part of the identifier
--(See elsewhere on the forum for help on that)
lmc_device_set_name('Keyboard', 'EXSTRING123')
--Initialise PTTToggled
PTTToggled = false
--Set the event handler for the keyboard events
lmc_set_handler('Keyboard',function(button, direction)
if(button == 0x65 and direction == 0)then --on KeyUp of the Numpad 5
PTTToggled = not PTTToggled --change state of PTTToggled
if (PTTToggled)then
lmc_send_input(0x87, 0, 0) --send KeyDown of F24
else
lmc_send_input(0x87, 0, 2) --send KeyUp of F24
end
end
end)
If you get the impression that this is spaghetti code written by someone whose native language is C#, that's because it is. Sorry about that.
On line 7 you'll need to replace "EXSTRING123" with a portion of the hardware identifying string for your keyboard.
0x65 and 0x87 are the virtual keycodes of the keys we're interested in. If you need to change them, you can find the table at
https://docs.microsoft.com/en-us/window ... -key-codes