Converting to using Async #375
Replies: 2 comments
-
The async API is pretty much identical to the sync API (in fact, the sync API is code-generated from the async API). It is documented in the readme. The migration path for you sounds pretty simple. You will just create your
Hmm. This sounds more like a question about using If you're not already familiar with using |
Beta Was this translation helpful? Give feedback.
-
@zxrobinson there's one thing you have to watch out for in using asyncio and that is the API would not support the handlers to be
If you simply just want to replace the block_forever so it doesn't do a spin lock or to add an emergency exit you can do the following import ahk
from threading import Event
lock = Event()
def stop_loop():
lock.set()
ahk.add_hotkey("^!+Backspace", callback=stop_loop)
lock.wait()
ahk.stop_hotkeys() This does not use a spin wait. Note the same technique with |
Beta Was this translation helpful? Give feedback.
-
I'd like to convert my existing sync ahk code to use async to avoid launching a new process with every call. When I do win_wait or win_get or whatever, do I have to wait for call to complete using sleep or something? Async examples equivalent to the Sync ones would be helpful. Even just a couple...
Beta Was this translation helpful? Give feedback.
All reactions