Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid Index when calling key_state() in v2 #277

Closed
newbiemate opened this issue Apr 3, 2024 · 2 comments · Fixed by #279
Closed

Invalid Index when calling key_state() in v2 #277

newbiemate opened this issue Apr 3, 2024 · 2 comments · Fixed by #279
Labels
bug Something isn't working

Comments

@newbiemate
Copy link

newbiemate commented Apr 3, 2024

describe your issue

Something with key_state() broke between v1 and v2:

check = ahk.key_state("~")

This was working fine in v1.

In v2, I got an invalid index error. The code didn't change between v1 -> v2, I only upgraded the ahk + ahk (python, v1.5.3) libraries.

ahk.version

2.0.12

AutoHotkey version

v2

Code to reproduce the issue

from ahk import AHK

ahk = AHK()
check = ahk.key_state("~")

Traceback/Error message

Traceback (most recent call last):
  File "C:\test\ahk\testpy", line 4, in <module>
    check = ahk.key_state("~")
  File "C:\test\ahk\env\lib\site-packages\ahk\_sync\engine.py", line 1092, in key_state
    resp = self._transport.function_call('AHKKeyState', args, blocking=blocking)
  File "C:\test\ahk\env\lib\site-packages\ahk\_sync\transport.py", line 611, in function_call
    return self.send(request, engine=engine)
  File "C:\test\ahk\env\lib\site-packages\ahk\_sync\transport.py", line 832, in send
    return response.unpack()  # type: ignore
  File "C:\test\ahk\env\lib\site-packages\ahk\message.py", line 221, in unpack
    raise self._exception_type(s)
ahk.message.AHKExecutionException: Error occurred in Array.Prototype.__Item.Get (line 1671). The error message was: Invalid index.. Specifically: 2
@spyoungtech spyoungtech added the bug Something isn't working label Apr 3, 2024
@spyoungtech
Copy link
Owner

Thanks. Confirmed the bug and reproduced. When the mode argument is not given, this bug appears when using AHK v2.

I should have a fix out for this today.

spyoungtech added a commit that referenced this issue Apr 3, 2024
fix key_state for AHKv2 when no mode argument is given
@spyoungtech
Copy link
Owner

The fix for this is now released in version 1.5.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants