AutoHotkey's GetKeyState() command no longer works properly on Windows 10 (As of 1809 or thereabouts) with non-xbox360 XInput controllers.
It will work fine while the AHK script is the active application, but as soon as you switch into a game, AHK will no longer be able to read the stick.
The solution is to use the XInput library
To clarify:
NOT AFFECTED (GetKeyState works OK):
Xbox 360 (Wired or Wireless)
AFFECTED (GetKeyState does NOT work OK)
Xbox One
Xbox Elite
XAC (Accessibility controller)
Trying to read XBox One / Elite pads with AutoHotkey? READ THIS BEFORE POSTING
Trying to read XBox One / Elite pads with AutoHotkey? READ THIS BEFORE POSTING
Last edited by lexikos on 01 Sep 2022, 16:55, edited 1 time in total.
Reason: update link
Reason: update link
Re: Trying to read XBox One / Elite pads with AutoHotkey? READ THIS BEFORE POSTING
Try this.
This is a script I wrote for using my PS4 controller.
This will work with any controller that is detected by your system.
But the Xbox numbers may be different from the PS4 layout. So change the Joy Numbers as shown on your controller property menu as needed.
You can ignore the function keys of the script.
Its part of a more complex program a made.
This is a script I wrote for using my PS4 controller.
This will work with any controller that is detected by your system.
But the Xbox numbers may be different from the PS4 layout. So change the Joy Numbers as shown on your controller property menu as needed.
You can ignore the function keys of the script.
Its part of a more complex program a made.
Code: Select all
START:
Loop
{
OFF:
Loop
{
M := GetKeyState(i "Joy14")
K := GetKeyState("F1")
While(m=1)
{
m:=GetkeyState(i "Joy14")
a=1
}
While(K=1)
{
K:=GetkeyState("F1")
a=1
}
If (a=1)
{
a=
break
}
}
ON:
Loop
{
m:=GetkeyState(i"Joy14")
K:=GetkeyState("F1")
While( m=1)
{
m:=GetkeyState(i "Joy14")
b=1
}
While(k=1)
{
K:=GetkeyState("F1")
b=1
}
If (b=1)
{
b=
break
}
}
}
CONROLLER_ACTIVATED:
Loop
{
/*
S=1
X=2
C=3
T=4
L1 Button = Joy5
R1 Button = Joy6
L2 Button = Joy7
R2 Button = Joy8
Share= Joy9
Option= Joy10
L3= Joy11
R3= Joy12
PS Button = Joy13
MousePad = Joy14
*/
start:= GetKeyState(i "Joy10")
select:= GetKeyState(i "Joy9")
S:= GetKeyState(i "Joy1") ;square
X:= GetKeyState(i "Joy2") ;ex
T:= GetKeyState(i "Joy3") ;triangle
C= GetKeyState(i "Joy4") ;circle
R2:= GetKeyState(i"Joy5")
R1:= GetKeyState(i "Joy6")
R3:= GetKeyState(i "Joy7")
L3:= GetKeyState(i "Joy8")
;------------------------<JOYSTICK>--------------------------------------/
X:= GetKeyState(i "JoyX") ;Left Joy>
Y:= GetKeyState(i "JoyY") ;Left Joy>
R:= GetKeyState(i "JoyR") ;<Right Joy>
Z:= GetKeyState(i "JoyZ") ;<Right Joy>
IfWinNotActive, FINAL FANTASY XIV
{
If (x < 40 or x > 60 or y < 40 or y > 60)
WinActivate, FINAL FANTASY XIV
If (r > 60 or r < 35)
WinActivate, FINAL FANTASY XIV
}
IF (i="error" or i="")
goto START
Sleep 100
}
-
- Posts: 4
- Joined: 25 Apr 2020, 03:13
Re: Trying to read XBox One / Elite pads with AutoHotkey? READ THIS BEFORE POSTING
Galaxis, can u help me?
i dont have 2 fingers on left hand and need macro to use left,up and right when press r1
can u help me?
find on web for pc..[Mod edit: [code][/code] tags added]
i dont have 2 fingers on left hand and need macro to use left,up and right when press r1
Code: Select all
Joy6:: ;R1
IfWinExist, PS4 Remote Play
{
WinActivate
Send Left,Up,Right (need use this buttons on ps4 controller)
}
find on web for pc..
Code: Select all
;pop all flasks
Random, rand, 100, 300
6::
IfWinActive Path of Exile ahk_class POEWindowClass
{
WinActivate
SendInput 1
Sleep rand
SendInput 2
Sleep rand
SendInput 3
Sleep rand
SendInput 4
Sleep rand
SendInput 5
}
return
Re: Trying to read XBox One / Elite pads with AutoHotkey? READ THIS BEFORE POSTING
andrelgago wrote: ↑25 Apr 2020, 10:38Galaxis, can u help me?
i dont have 2 fingers on left hand and need macro to use left,up and right when press r1
can u help me?Code: Select all
Joy6:: ;R1 IfWinExist, PS4 Remote Play { WinActivate Send Left,Up,Right (need use this buttons on ps4 controller) }
find on web for pc..[Mod edit: [code][/code] tags added]Code: Select all
;pop all flasks Random, rand, 100, 300 6:: IfWinActive Path of Exile ahk_class POEWindowClass { WinActivate SendInput 1 Sleep rand SendInput 2 Sleep rand SendInput 3 Sleep rand SendInput 4 Sleep rand SendInput 5 } return
Code: Select all
START:
Loop
{
OFF:
Loop
{
M := GetKeyState(i "Joy14")
K := GetKeyState("F1")
While(m=1)
{
m:=GetkeyState(i "Joy14")
a=1
}
While(K=1)
{
K:=GetkeyState("F1")
a=1
}
If (a=1)
{
a=
break
}
}
ON:
Loop
{
m:=GetkeyState(i"Joy14")
K:=GetkeyState("F1")
While( m=1)
{
m:=GetkeyState(i "Joy14")
b=1
}
While(k=1)
{
K:=GetkeyState("F1")
b=1
}
If (b=1)
{
b=
break
}
}
}
CONROLLER_ACTIVATED:
Loop
{
/*
S=1
X=2
C=3
T=4
L1 Button = Joy5
R1 Button = Joy6
L2 Button = Joy7
R2 Button = Joy8
Share= Joy9
Option= Joy10
L3= Joy11
R3= Joy12
PS Button = Joy13
MousePad = Joy14
*/
start:= GetKeyState(i "Joy10")
select:= GetKeyState(i "Joy9")
S:= GetKeyState(i "Joy1") ;square
X:= GetKeyState(i "Joy2") ;ex
T:= GetKeyState(i "Joy3") ;triangle
C= GetKeyState(i "Joy4") ;circle
R2:= GetKeyState(i"Joy5")
R1:= GetKeyState(i "Joy6")
R3:= GetKeyState(i "Joy7")
L3:= GetKeyState(i "Joy8")
;------------------------<JOYSTICK>--------------------------------------/
X:= GetKeyState(i "JoyX") ;Left Joy>
Y:= GetKeyState(i "JoyY") ;Left Joy>
R:= GetKeyState(i "JoyR") ;<Right Joy>
Z:= GetKeyState(i "JoyZ") ;<Right Joy>
If R1=1
Send, {left}{up}{right}
Sleep 100
}
Just add this to the buttom of the script:
If R1=1
Send, {left}{up}{right}
But you need to go to your joystick settings/properties to confirm the number for R1 is Joy6, and change this if it's different. This can change from PS3 to PS4 to generic controllers.
-
- Posts: 4
- Joined: 25 Apr 2020, 03:13
Re: Trying to read XBox One / Elite pads with AutoHotkey? READ THIS BEFORE POSTING
try to run but not working....
use on ps4 original controller,,,
the correct name is: Send, {left}{up}{right} ?
need use this but this is the correct name?left,....
i dont know about AHK, but see
X:= GetKeyState(i "JoyX") ;Left Joy>
Y:= GetKeyState(i "JoyY") ;Left Joy>
R:= GetKeyState(i "JoyR") ;<Right Joy>
Z:= GetKeyState(i "JoyZ") ;<Right Joy>
use on ps4 original controller,,,
the correct name is: Send, {left}{up}{right} ?
need use this but this is the correct name?left,....
i dont know about AHK, but see
X:= GetKeyState(i "JoyX") ;Left Joy>
Y:= GetKeyState(i "JoyY") ;Left Joy>
R:= GetKeyState(i "JoyR") ;<Right Joy>
Z:= GetKeyState(i "JoyZ") ;<Right Joy>
Re: Trying to read XBox One / Elite pads with AutoHotkey? READ THIS BEFORE POSTING
Pressing R1 doesn't send another controller input. It is sending Left, Up, Right from the keyboard. It will not send those Joystick Axis.
{Left} {Up} {Right} are keyboard inputs.
Key1:=GetKeyState(i "JoyX") cannot send another such as: Key2:= GetKeyState(i "JoyZ")
Joy are controller inputs. Joy for R1 cannot send JoyX or JoyZ. Only Keyboard keys.
{Left} {Up} {Right} are keyboard inputs.
Key1:=GetKeyState(i "JoyX") cannot send another such as: Key2:= GetKeyState(i "JoyZ")
Joy are controller inputs. Joy for R1 cannot send JoyX or JoyZ. Only Keyboard keys.
Re: Trying to read XBox One / Elite pads with AutoHotkey? READ THIS BEFORE POSTING
Is it possible to create a script that will act as a rapid fire with the xbox one controller connected to the pc?
Can anyone help with such a script?
It's about the default fire button under RT
Can anyone help with such a script?
It's about the default fire button under RT
Who is online
Users browsing this forum: Desmonddet and 18 guests