Closed xx299x closed 11 months ago
Hmm. I'm not sure I fully understand this example.
The way I understand this, you've done three things in the shared AutoHotkey code:
e
to e
(which seems to have no real practical effect)i
o
Right now, AutoHotkey's "remapping" feature isn't directly implemented. But hotstrings with the *
modifier (not requiring ending keys) should have a similar effect.
So, this Python code using hotstrings has the same effects as the code you shared:
from ahk import AHK
ahk = AHK()
def i_action():
ahk.msg_box('i')
def o_action():
ahk.msg_box('o')
ahk.add_hotstring('e', 'e', options='*')
ahk.add_hotstring('i', i_action, options='*')
ahk.add_hotstring('o', o_action, options='*')
ahk.start_hotkeys()
ahk.block_forever()
When I test this Python code and the AHK code you provided, the effect seems to be identical.
How to implement the behavior of the script above? When pressing 'e,' it functions as a regular 'e,' but when 'e' is combined with 'i' or 'o,' it performs their respective actions.
This is a very useful approach. When developing a keyboard shortcut system, considering AHK's peculiar syntax, I'd like to rewrite my shortcut system in Python.