Advertisement
Azelphur

Untitled

Nov 29th, 2011
374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #NoTrayIcon
  2. #Persistent  ; Keep this script running until the user explicitly exits it.
  3. JoystickNumber = 1
  4.  
  5. SetTimer, WatchAxis, 5
  6. return
  7.  
  8. WatchAxis:
  9. GetKeyState, JoyX, %JoystickNumber%JoyX
  10. GetKeyState, JoyY, %JoystickNumber%JoyY
  11. GetKeyState, joy_name, %JoystickNumber%JoyName
  12. KeyToHoldDownPrev = %KeyToHoldDown%  ; Prev now holds the key that was down before (if any).
  13.  
  14. KeyToHoldDown =
  15.  
  16. if JoyX > 51.0
  17.     KeyToHoldDown = d
  18. if JoyX < 49.0
  19.     KeyToHoldDown = %KeyToHoldDown% a
  20.  
  21. button = %JoystickNumber%Joy3
  22. if GetKeyState(button) {
  23.    KeyToHoldDown = %KeyToHoldDown% w
  24. }
  25.  
  26. button = %JoystickNumber%Joy4
  27. if GetKeyState(button) {
  28.    KeyToHoldDown = %KeyToHoldDown% s
  29. }
  30.  
  31. button = %JoystickNumber%Joy2
  32. if GetKeyState(button) {
  33.    KeyToHoldDown = %KeyToHoldDown% Space
  34. }
  35.  
  36. button = %JoystickNumber%Joy5
  37. if GetKeyState(button) {
  38.    KeyToHoldDown = %KeyToHoldDown% 3
  39. }
  40.  
  41. button = %JoystickNumber%Joy6
  42. if GetKeyState(button) {
  43.    KeyToHoldDown = %KeyToHoldDown% 4
  44. }
  45.  
  46. button = %JoystickNumber%Joy7
  47. if GetKeyState(button) {
  48.    KeyToHoldDown = %KeyToHoldDown% 1
  49. }
  50.  
  51. button = %JoystickNumber%Joy8
  52. if GetKeyState(button) {
  53.    KeyToHoldDown = %KeyToHoldDown% 2
  54. }
  55.  
  56. if KeyToHoldDown = %KeyToHoldDownPrev%
  57.     return  ; Do nothing.
  58.  
  59. ; Otherwise, release the previous key and press down the new key:
  60. SetKeyDelay -1  ; Avoid delays between keystrokes.
  61. if KeyToHoldDownPrev {
  62.     StringSplit, PrevArray, KeyToHoldDownPrev, %A_Space%
  63.     Loop, %PrevArray0%
  64.     {
  65.         key := PrevArray%a_index%
  66.         Send, {%key% up}  ; Release it.
  67.     }
  68. }
  69. if KeyToHoldDown {
  70.     StringSplit, CurrArray, KeyToHoldDown, %A_Space%
  71.     Loop, %CurrArray0%
  72.     {
  73.         key := CurrArray%a_index%
  74.         Send, {%key% down}  ; Press it down.
  75.     }
  76. }
  77. return
  78.  
  79.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement