Closed zzsimplezz closed 5 months ago
Thanks. Reproduced and confirmed. I should be able to have a fix out shortly.
This should now be fixed in v1.7.5
Keep in mind, AutoHotkey v2 uses Input
as its default SendMode. As noted in the SetKeyDelay documentation, key delay has no effect when the SendMode is Input
.
So, if you're using AutoHotkey v2, you'll have to change the send mode in order to see the effect of the key_delay
parameter take place properly:
from ahk import AHK
ahk = AHK(version='v2')
ahk.send('anything', key_delay=50, send_mode='Event')
# OR
ahk.set_send_mode('Event')
ahk.send('anything', key_delay=50)
Please try out the latest version and let me know if that fixes the problem or if you have any other issues. Thanks!
It seems like the method set_send_mode
dont have type definition => it doesn"t show in vscode suggestion. Can you check and fix it??
Hmm. @zzsimplezz The method does have type hints and I can see it properly in my PyCharm editor. I'm not sure why vscode would not show it.
The accepted arguments are the same as in AutoHotkey's SendMode
.
The signature looks like this.
SendMode: TypeAlias = Literal['Event', 'Input', 'InputThenPlay', 'Play', ''] # defined in `_types.py`
def set_send_mode(self, mode: SendMode) -> None:
...
And can be found here for the async version and here for the sync version.
We use mypy with strict type checking, which does not allow untyped definitions and those checks also pass. My best guess is it may be a problem with vscode. If you're using a version of Python 3.10 or earlier, make sure you have typing_extensions
installed in your vscode environment (though, I'm not sure why it would be missing since this is installed automatically when needed when you install ahk
).
describe your issue
cmd:
ahk.send(keyStr, key_delay=50)
ahk.message.AHKExecutionException: Error occurred in SetKeyDelay (line 1850). The error message was: Parameter #2 of SetKeyDelay requires a Number, but received an empty string..
Thank you for your lib. :D
ahk.version
No response
AutoHotkey version
v2
Code to reproduce the issue
Traceback/Error message
No response