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

Ask gaming related questions
User avatar
evilC
Posts: 4765
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: 42
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



}

Return to “Gaming”

Who is online

Users browsing this forum: Rohwedder and 39 guests