Lexikos wrote:
The code in red is interpreted as literal text:
Code:
if JoyX > 70 and JoyY < 30
The equivalent expression is:
Code:
if (JoyX > "70 and JoyY < 30")
What you probably want is:
Code:
if (JoyX > 70 and JoyY < 30)
Thanks very much,Lexikos
I changed the code ,and it works someway,though its behave is not easy
to control, when I push the left up direction,sometimes it send 7,sometimes 47 ,sometimes 478, the left,up,down,right direction works very well,may be I should use two axises, left axis for 4 8 6 2,right axis for 1 7 9 3.
Code:
#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% ; Prev now holds the key that was down before (if any).
if (JoyX > 70 and JoyY < 30)
KeyToHoldDown = numpad9
else if (JoyX > 70 and JoyY > 70)
KeyToHoldDown = numpad3
else if (JoyX < 30 and JoyY < 30)
KeyToHoldDown = numpad7
else if (JoyX < 30 and JoyY > 70)
KeyToHoldDown = numpad1
else if JoyX > 70
KeyToHoldDown = numpad6
else if JoyX < 30
KeyToHoldDown = numpad4
else if JoyY > 70
KeyToHoldDown = numpad2
else if JoyY < 30
KeyToHoldDown = numpad8
else
KeyToHoldDown =
if KeyToHoldDown = %KeyToHoldDownPrev% ; The correct key is already down (or no key is needed).
return ; Do nothing.
; Otherwise, release the previous key and press down the new key:
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.
return
joy11::
send 5
return