is there full Hotkey and Hotstring support? #155
-
Hi, I was wondering If there was support for everything that has to do with hotkeys and hotstrings? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Almost. Technically, every functionality of AHK is supported through the Hotstrings that run scripts can work by using the hotkey API. I'll make a note to implement hotstrings for simple text replacement in the near future. Using the Hotkey API, you can do this: import time
from ahk import AHK
ahk = AHK()
hotstring = ahk.hotkey('::btw', 'MsgBox you typed "btw".')
hotstring.start()
print('hotstring active! Press ctrl+c to stop')
# add a loop to stop the Python script from exiting
while True:
try:
time.sleep(0.5)
except KeyboardInterrupt:
hotstring.stop() # stop the hotstring script
break This is equivalent to the AHK script: ::btw::
MsgBox You typed "btw".
return You can also implement hotstrings yourself using ahk = AHK()
hotstring = ahk.run_script('::btw::by the way', blocking=False)
print('hotstring active! Press ctrl+c to stop')
# add a loop to stop the Python script from exiting
while True:
try:
time.sleep(0.5)
except KeyboardInterrupt:
hotstring.terminate() # stop the hotstring script
break |
Beta Was this translation helpful? Give feedback.
Almost. Technically, every functionality of AHK is supported through the
.run_script
API. Hotkeys are supported directly in the API (ahk.hotkey
), but Hotstrings for text replacement (e.g.::btw::by the way
) are not directly supported by the API.Hotstrings that run scripts can work by using the hotkey API.
I'll make a note to implement hotstrings for simple text replacement in the near future.
Using the Hotkey API, you can do this: