Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 21st, 2012  |  syntax: None  |  size: 1.00 KB  |  hits: 33  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #Persistent  ; Keep this script running until the user explicitly exits it.
  2. SetTimer, WatchAxis, 5
  3. JoyStickID = 0
  4. return
  5.  
  6. WatchAxis:
  7. GetKeyState, %JoyStickID%JoyX, JoyX  ; Get position of X axis.
  8. GetKeyState, %JoyStickID%JoyY, JoyY  ; Get position of Y axis.
  9. KeyToHoldDownPrev = %KeyToHoldDown%  ; Prev now holds the key that was down before (if any).
  10.  
  11. if JoyX > 70
  12.     KeyToHoldDown = D
  13. else if JoyX < 30
  14.     KeyToHoldDown = A
  15. else if JoyY > 70
  16.     KeyToHoldDown = S
  17. else if JoyY < 30
  18.     KeyToHoldDown = W
  19. else
  20.     KeyToHoldDown =
  21.  
  22. if KeyToHoldDown = %KeyToHoldDownPrev%  ; The correct key is already down (or no key is needed).
  23.     return  ; Do nothing.
  24.  
  25. ; Otherwise, release the previous key and press down the new key:
  26. SetKeyDelay -1  ; Avoid delays between keystrokes.
  27. if KeyToHoldDownPrev   ; There is a previous key to release.
  28.     Send, {%KeyToHoldDownPrev% up}  ; Release it.
  29. if KeyToHoldDown   ; There is a key to press down.
  30.     Send, {%KeyToHoldDown% down}  ; Press it down.
  31. return