You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am not very good at speaking English. I use AI to assist in communication.
I really appreciate your AHK project, it has been very helpful to me. Thank you very much for the effort and time you've invested in it.
Recently, I encountered a problem while using this library. When I hold down a hotkey continuously, it keeps calling the Python function associated with that hotkey. Sometimes, under the Win11 system, a prompt pops up after triggering the hotkey, as shown in the following figure.
Hmmm. There is a subtle difference in how Hotkeys work under this library. Specifically, the hotkey execution in the AHK process just simply causes Python to queue up the callback and finishes almost instantly.
Normally, AutoHotkey stops the same hotkey from running at the same time. But because the implementation here has the callback finish almost instantly, it means the hotkey can be called many times rapidly.
It is often suggested to do something like this in AutoHotkey:
^n::
; ...KeyWait n ; holds the hotkey in execution until the key is released
The behavior unfortunately doesn't work as intended if you try to do the same thing in Python because, as far as AutoHotkey is concerned, the hotkey is already done even if the Python callback is still executing.
There may be room for improvement in how the library dispatches hotkey callbacks to more closely emulate the default behavior of AutoHotkey (e.g., dropping dispatches for hotkeys that are still running).
The only workaround I can think of right now is not ideal. But perhaps you can use a global variable to get this behavior:
This probably won't solve your problem of potentially exceeding the maximum hotkey interval (on my system, this didn't happen, however). There will still be a lot of threads and calls to the callback function, but the function just turns into a no-op while another instance is running.
Right now, the MaxHotkeysPerInterval directive can be used with AHK v1 (this is not supported in this library when using v2, since AHK removed the directive and replaced it with A_MaxHotkeyInterval) -- you may be able to alleviate the problem by reducing your keyboard's key repeat rate in Windows settings.
Checked the documentation
describe your feature request
I am not very good at speaking English. I use AI to assist in communication.
I really appreciate your AHK project, it has been very helpful to me. Thank you very much for the effort and time you've invested in it.
Recently, I encountered a problem while using this library. When I hold down a hotkey continuously, it keeps calling the Python function associated with that hotkey. Sometimes, under the Win11 system, a prompt pops up after triggering the hotkey, as shown in the following figure.
The simplified code is as follows:
My requirements are as follows:
In response to my requirements, how should I modify the aforementioned code?
The text was updated successfully, but these errors were encountered: