Jump to content
LaunchBox Community Forums
thedevilsjester

Joypad keys not working in AHK?

Recommended Posts

Posted (edited)

I was originally going to post a question about an issue I was having; but the engineer in me wanted to dig in just a little deeper, and I found the solution (of sorts).

After months, my AutoHotKey scripts (via LB) just ... stopped working.  Nothing has changed, the hardware is the same, the software is the same, the input devices are the same, etc...  As it turns out, AutoHotKey was working just fine, but it didn't seem like it was detecting my controller.  Some more digging and running scripts to enumerate the controllers AHK can see, and immediately I discovered that the only controller on the system was being reported as controller 2!

So I had to change all of my scripts that referenced Joy to 2Joy and everything just worked again.  Unfortunately I don't know why it changed, and if/when it will change again, so I will likely have to update my scripts every time it randomly breaks.

Apparently its a known issue (see the note here) https://www.autohotkey.com/docs/KeyList.htm#Joystick but there doesn't seem to be a solution and the "one person reported" portion of the note doesn't seem like its widespread enough to matter.  So if your Joy keys stop working in AHK, or don't work at all when they should, check and see if its actually the first joypad.

I am putting this out there so that anyone else that runs into this situation will have a resource to find as I was not able to find any topic that discussed this.

Edited by thedevilsjester

Share this post


Link to post
Share on other sites

When this happened, was there some other device of-sorts [that was not your controller] being reported as 1joy?

If not, and assuming you're only using one controller, I wonder if you could, at the beginning of your called scripts add something like what they have in the Joystick Test Script (referenced in your link).

JoystickNumber = 0
if JoystickNumber <= 0
{
    Loop 16  ; Query each joystick number to find out which ones exist.
    {
        GetKeyState, JoyName, %A_Index%JoyName
        if JoyName <>
        {
            JoystickNumber = %A_Index%
            break
        }
    }
    if JoystickNumber <= 0
    {
        ;MsgBox The system does not appear to have any joysticks.
        ExitApp
    }
}

Probably only Loop 4 (max).  Then in the rest of your regular code below this......   all references to 1joy (or as of your new found discovery... 2joy), change to %JoystickNumber%joy

Again, this'd only work if you're using 1 controller AND if something else isn't stealing away the name "1joy".  Just a (untested) thought. :$

Share this post


Link to post
Share on other sites

No there wasn't any device reporting as 1Joy, in fact I used that script as a basis to enumerate the Joypads detected on my system.

I am playing with possibilities, I will certainly write something more flexible in the future.  I just wanted to put this information out there so others could find it as well.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...