Stopping all executions related to an AHK instance #205
Replies: 1 comment 1 reply
-
I suppose it's possible for a hotkey to trigger a Python function that forcibly terminates all AHK processes. Maybe something like this? def kill_ahk():
subprocess.run(['taskkill', '/F', '/IM', 'AutoHotkey.exe']) # or similar? Process image may be different.
# win+k to kill all autohotkey processes
ahk.add_hotkey('#k', callback=kill_ahk) But that will obviously cause problems if subsequent commands are issued. But all processes are supposed to be cleaned up at exit ( There's currently no graceful shutdown command and it's something I'd like to add to the API. Right now, there is just an (internal) api to kill the process(es). For example, to kill the main process used to run non-hotkey/hotstring command: ahk._transport._proc.kill() Hotkeys use a separate process that can also be killed similarly (I think this works). ahk._transport._hotkey_transport._proc.kill() You can also see some of this in the unittest teardowns, like as seen here. Of course, these internal APIs are subject to change and I wouldn't recommend relying on them. But I think the ideal solution would be to have a public API to gracefully (and maybe optionally, forcefully) shutdown the process(es) used by |
Beta Was this translation helpful? Give feedback.
-
I have an AHK instance which is being used to run AHK commands somewhere.
I also use the same AHK instance to listen for hotkeys.
Is there a way for a hotkey to cause all uses of the AHK instance to stop, including the commands not called by hotkeys?
Something like the ExitApp or Exit functions in the actual AHK
Thanks for any responses in advance
Beta Was this translation helpful? Give feedback.
All reactions