Long time AutoHotkey user. First time Linux user. Really struggling to find something as elegant as AutoHotkey.
Playing a browser based game, it has you use accessibility commands to speed up playing. E.g. Ctrl+1 to select choice 1.
So my end goal is to be able to just press the "Numpad1" key (Which apparently is just <np_end> to AutoKey regardless of the state of the NumLock) and have it send Ctrl+1. This way I can play with just one hand as opposed to two.
The code I would work is
keyboard.press_key('<ctrl>')
keyboard.send_key('1')
keyboard.release_key('<ctrl>')
But all that does is send a 1, no ctrl. I tested it with other classic commands like ctrl+a or ctrl+s by substituting the send_key('1') for send_key('a') or send_key('s') to make it do a select all or save page command. It's not doing that. It's like the Ctrl key doesn't register at all. It just keeps typing the letter.
This is on 0.96.0 or whatever is the latest as of Aug 15 2022.
I googled up an example documentation here:
And it says this should work just fine:
keyboard.press_key('<ctrl>')
keyboard.send_key('d', repeat=5)
keyboard.release_key('<ctrl>')
But, it doesn't. It just types the letter d 5 times instead of trying to open up add-to-bookmarks in my browser. I don't believe Firefox would have any "anti automatic input" detection that it would ignore the Ctrl key, but, hey, it doesn't work anyway!
I am trying to use the window filter setting to match only when I'm on the correct webpage in Firefox. It almost works. I can't actually use the Numpad1 key outside of the webpage, like when typing up this conversation, but it does work in other applications like AutoKey's GUI itself or in Thunderbird.
Further request would be is it possible like in AutoHotkey to define multiple hotkeys in a script? Like if I want to use Numpad1, Numpad2, Numpad3, Numpad4, etc. all in one script, where a Numpad0 can actually serve as a toggle for this remapping functionality? This would be an example AutoHotkey script:
Numpad0::toggle:=!toggle ; changes value of toggle variable from false to true or true to false
#If toggle ; if this is true
Numpad1::SendInput ^{Numpad1} ; ^ being the Ctrl modifier
Numpad2::SendInput ^{Numpad2}
#If ; close out the if because of the weird #if directive having an effect of "looping" to the top of the script, so this is telling Numpad0 to always work in any context
The way I'm envisioning myset up in AutoKey for now is making separate scripts each with a different hotkey for each remapping I want, but I don't see a way to easily enable/disable them with a 10th hotkey.