Trying to read XBox One / Elite pads with AutoHotkey? READ THIS BEFORE POSTING

Ask gaming related questions
User avatar
evilC
Posts: 4780
Joined: 27 Feb 2014, 12:30

Trying to read XBox One / Elite pads with AutoHotkey? READ THIS BEFORE POSTING

04 Feb 2019, 06:02

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)
Galaxis
Posts: 48
Joined: 04 Feb 2016, 20:09

Re: Trying to read XBox One / Elite pads with AutoHotkey? READ THIS BEFORE POSTING

16 Dec 2019, 02:22

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.

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



}
andrelgago
Posts: 4
Joined: 25 Apr 2020, 03:13

Re: Trying to read XBox One / Elite pads with AutoHotkey? READ THIS BEFORE POSTING

25 Apr 2020, 10:38

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


Code: Select all

Joy6::                  ;R1 

IfWinExist, PS4 Remote Play

{
WinActivate
Send Left,Up,Right                         (need use this buttons on ps4 controller)
}
can u help me?




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
[Mod edit: [code][/code] tags added]
Galaxis
Posts: 48
Joined: 04 Feb 2016, 20:09

Re: Trying to read XBox One / Elite pads with AutoHotkey? READ THIS BEFORE POSTING

25 Apr 2020, 16:22

andrelgago wrote:
25 Apr 2020, 10:38
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


Code: Select all

Joy6::                  ;R1 

IfWinExist, PS4 Remote Play

{
WinActivate
Send Left,Up,Right                         (need use this buttons on ps4 controller)
}
can u help me?




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
[Mod edit: [code][/code] tags added]

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.
andrelgago
Posts: 4
Joined: 25 Apr 2020, 03:13

Re: Trying to read XBox One / Elite pads with AutoHotkey? READ THIS BEFORE POSTING

26 Apr 2020, 00:31

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>
Galaxis
Posts: 48
Joined: 04 Feb 2016, 20:09

Re: Trying to read XBox One / Elite pads with AutoHotkey? READ THIS BEFORE POSTING

26 Apr 2020, 09:02

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.

Return to “Gaming”

Who is online

Users browsing this forum: LunarSummer and 15 guests