Looking for Axis to arrow keys rebind (with diagonals!)

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Crimson_V
Posts: 9
Joined: 14 May 2016, 06:54

Looking for Axis to arrow keys rebind (with diagonals!)

24 Oct 2017, 13:20

Hello i was wondering if any of you have an axis to arrow key rebind script (with diagonals)?

so far the only working script i found was from JonA and it has some problems.

Code: Select all

#Persistent
SetTimer, WatchAxis, 5

return

WatchAxis:
GetKeyState, JoyX, JoyX
GetKeyState, JoyY, JoyY

     If JoyX < 30
{
     Send {Left down}   
SetTimer, WaitForJoyX, 30
return

WaitForJoyX:
if JoyX > 29  
{
    Send {Left up}  
    SetTimer, WaitForJoyX, off  
    return
}

Send {Left down}  
return
}

else If JoyX > 70
{
     Send {Right down}   
SetTimer, WaitForJoyX2, 30
return

WaitForJoyX2:
if JoyX < 71  
{
    Send {Right up}  
    SetTimer, WaitForJoyX2, off  
    return
}

Send {Right down}  
return
}

     If JoyY < 30
{
     Send {Up down}   
SetTimer, WaitForJoyY, 30
return

WaitForJoyY:
if JoyY > 29  
{
    Send {Up up}  
    SetTimer, WaitForJoyY, off  
    return
}

Send {Up down}  
return
}

     If JoyY > 70
{
     Send {Down down}   
SetTimer, WaitForJoyY2, 30
return

WaitForJoyY2:
if JoyY < 71  
{
    Send {Down up}  
    SetTimer, WaitForJoyY2, off  
    return
}

Send {Down down}  
return
}
return
couldn't figure out how to fix this one (when moving axis from right/left to up it skips the diagonal only works the other way around),
so if any of you have a working script with diagonals (or an idea how to fix this one) please help me out.
Crimson_V
Posts: 9
Joined: 14 May 2016, 06:54

Re: Looking for Axis to arrow keys rebind (with diagonals!)

26 Oct 2017, 12:42

for anyone googling this and also looking for an axis to arrow with diagonals scripts, i finally made a decent one, i'm not great at coding so the struggle was real but here it is:

Code: Select all

#Persistent  ; Keep this script running until the user explicitly exits it.
SetTimer, WatchAxis, 5
return

WatchAxis:
GetKeyState, JoyX, JoyX  ; Get position of X axis.
GetKeyState, JoyY, JoyY  ; Get position of Y axis.
KeyToHoldDownPrev = %KeyToHoldDown%
KeyToHoldDownPrev2 = %KeyToHoldDown2%

if (JoyX > 70 and JoyY > 30 and JoyY < 70)
	{
	KeyToHoldDown = Right
	KeyToHoldDown2 =
	}
else if (JoyX > 70 and JoyY > 70)
	{
	KeyToHoldDown = Right
	KeyToHoldDown2 = Down
	}
else if (JoyY > 70 and JoyX > 30 and JoyX < 70)
	{
	KeyToHoldDown =
	KeyToHoldDown2 = Down
	}
else if (JoyY > 70 and JoyX < 30)
	{
	KeyToHoldDown = Left
	KeyToHoldDown2 = Down
	}
else if (JoyX < 30 and JoyY > 30 and JoyY < 70)
	{
	KeyToHoldDown = Left
	KeyToHoldDown2 =
	}
else if (JoyX < 30 and JoyY < 30)
	{
	KeyToHoldDown = Left
	KeyToHoldDown2 = Up
	}
else if (JoyY < 30 and JoyX > 30 and JoyX < 70)
	{
	KeyToHoldDown =
	KeyToHoldDown2 = Up
	}
else if (JoyX > 70 and JoyY < 30)
	{
	KeyToHoldDown = Right
	KeyToHoldDown2 = Up
	}
else if (JoyX > 30 and JoyX < 70 and JoyY > 30 and JoyY < 70)
	{
	KeyToHoldDown =
	KeyToHoldDown2 =
	}


if KeyToHoldDown != %KeyToHoldDownPrev% 
	{
	SetKeyDelay -1  ; Avoid delays between keystrokes.
	if KeyToHoldDownPrev   ; There is a previous key to release.
		Send, {%KeyToHoldDownPrev% up}  ; Release it.
	if KeyToHoldDown   ; There is a key to press down.
		Send, {%KeyToHoldDown% down}  ; Press it down.
	}

if KeyToHoldDown2 != %KeyToHoldDownPrev2% 
	{
	SetKeyDelay -1  ; Avoid delays between keystrokes.
	if KeyToHoldDownPrev2   ; There is a previous key to release.
		Send, {%KeyToHoldDownPrev2% up}  ; Release it.
	if KeyToHoldDown2   ; There is a key to press down.
		Send, {%KeyToHoldDown2% down}  ; Press it down.
	}
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 382 guests