Joy key hotkey only works on ahk window Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
byzod
Posts: 89
Joined: 21 Jun 2021, 06:46

Joy key hotkey only works on ahk window

03 Mar 2023, 23:54

I try to bind share button on my xbox x controller to screenshot, but it's not working

After several test I found that it only works when ahk window is actived, any help?

Code I use to test:
joybtntest.ahk
(62 Bytes) Downloaded 46 times

Code: Select all

; joy test
Joy1::
{
	MsgBox("The A button was pressed.")
}
Press A button of controller when on window of notepad/firefox/full-screen game/window game/steam/etc. : not working

Press A button of controller when on window of ahk: working :eh:
1.jpg
1.jpg (91.07 KiB) Viewed 1199 times
User avatar
boiler
Posts: 17209
Joined: 21 Dec 2014, 02:44

Re: Joy key hotkey only works on ahk window

04 Mar 2023, 02:51

Is that the exact full script that you run with absolutely no other lines at all? It looks to be the case based on the line numbers in the image, but just making sure. Do you have any other scripts running? Are any other applications that are used to map controllers running?
byzod
Posts: 89
Joined: 21 Jun 2021, 06:46

Re: Joy key hotkey only works on ahk window

04 Mar 2023, 04:31

@boiler
Yes. No. No.
An2.gif
An2.gif (316.55 KiB) Viewed 1174 times
User avatar
boiler
Posts: 17209
Joined: 21 Dec 2014, 02:44

Re: Joy key hotkey only works on ahk window

04 Mar 2023, 08:36

I am away from where I have my controller for a while, so I can't test it myself.

What happens when you run the Joystick Test Script from the script showcase in the documentation?
neogna2
Posts: 598
Joined: 15 Sep 2016, 15:44

Re: Joy key hotkey only works on ahk window  Topic is solved

04 Mar 2023, 08:50

This is a known limitation. In Windows 10 and 11 with newer Xbox controllers (those released after the Xbox 360 controller) built in hotkeys like Joy1 and and GetKeyState reading of controller states only works when an AutoHotkey window has focus. To get them working when other windows are active you have to use XInput.
Here is the thread with the v2 version of XInput.ahk by Lexikos
viewtopic.php?f=83&t=106254

Edit: I should add that the share button is not detectable even with XInput, at least I found no way to do it. See the linked thread for discussion about that.
Last edited by neogna2 on 04 Mar 2023, 09:05, edited 1 time in total.
User avatar
boiler
Posts: 17209
Joined: 21 Dec 2014, 02:44

Re: Joy key hotkey only works on ahk window

04 Mar 2023, 08:56

Thanks for that info, @neogna2. I was not aware of that as I have an older Xbox controller.
byzod
Posts: 89
Joined: 21 Jun 2021, 06:46

Re: Joy key hotkey only works on ahk window

04 Mar 2023, 11:55

boiler wrote:
04 Mar 2023, 08:36
I am away from where I have my controller for a while, so I can't test it myself.

What happens when you run the Joystick Test Script from the script showcase in the documentation?
Still the same
An3.gif
An3.gif (434.93 KiB) Viewed 1123 times
neogna2 wrote:
04 Mar 2023, 08:50
This is a known limitation. In Windows 10 and 11 with newer Xbox controllers (those released after the Xbox 360 controller) built in hotkeys like Joy1 and and GetKeyState reading of controller states only works when an AutoHotkey window has focus. To get them working when other windows are active you have to use XInput.
Here is the thread with the v2 version of XInput.ahk by Lexikos
viewtopic.php?f=83&t=106254

Edit: I should add that the share button is not detectable even with XInput, at least I found no way to do it. See the linked thread for discussion about that.
Thanks for that!
Then I can give up trying to make it with vanilla hotkey, the xinput lib looks complicated but seems it's my only possible solution

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: No registered users and 43 guests