Advertisement
Guest User

Untitled

a guest
Feb 19th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #InstallKeybdHook
  2. SetTimer, WatchAxis, 5
  3. SetTimer, WatchJoy5, 5
  4. keys = 1,2,3,4,5,6,7,8,9,0,= ; key-names/scan-codes to accelarate
  5. Loop Parse, keys, `,
  6. Hotkey *%A_LoopField%, KEY
  7. return
  8.  
  9. KEY:
  10. StringTrimLeft key, A_ThisHotKey, 1
  11. t := 0.1 ; initial delay [seconds]
  12. ctrlkey := GetKeyState("Ctrl")
  13. shiftkey := GetKeyState("Shift")
  14. altkey := GetKeyState("Alt")
  15.  
  16. if shiftkey {
  17.     while shiftkey {
  18.         Send +{BLIND}{%key%}
  19.         KeyWait %key%, T%t%
  20.         If ErrorLevel = 0
  21.         Break
  22.         t := 0.1 ; delay *= 1, while delay > 0.2
  23.         shiftkey := GetKeyState("Shift")
  24.     }
  25.     KeyWait %key%
  26.     return
  27. }
  28.  
  29. else if ctrlkey {
  30.     while ctrlkey {
  31.         if ((GetKeyState("4", "P")) || (GetKeyState("5", "P")) || GetKeyState("6", "P")) {
  32.             Send ^{BLIND}{%key%}
  33.             Break
  34.             }
  35.         Send ^{BLIND}{%key%}
  36.         KeyWait %key%, T%t%
  37.         If ErrorLevel = 0
  38.         Break
  39.         t := 0.1 ; delay *= 1, while delay > 0.2
  40.         ctrlkey := GetKeyState("Ctrl")
  41.     }    
  42.     KeyWait %key%
  43.     return
  44. }
  45.  
  46. else if altkey {
  47.     while altkey {
  48.         Send !{BLIND}{%key%}
  49.         KeyWait %key%, T%t%
  50.         If ErrorLevel = 0
  51.         Break
  52.         t := 0.1 ; delay *= 1, while delay > 0.2
  53.         altkey := GetKeyState("Alt")
  54.         }
  55.     KeyWait %key%
  56.     return
  57. }
  58.  
  59. else if not (shiftkey || altkey || ctrlkey) {
  60.     while not (shiftkey || altkey || ctrlkey) {
  61.         Send {BLIND}{%key%}
  62.         KeyWait %key%, T%t%
  63.         If ErrorLevel = 0
  64.         Break
  65.         t := 0.1 ; delay *= 1, while delay > 0.2
  66.         shiftkey := GetKeyState("Shift")
  67.         ctrlkey := GetKeyState("Ctrl")
  68.         altkey := GetKeyState("Alt")
  69.     }
  70.  
  71.         KeyWait %key%
  72.         return
  73. }
  74. return
  75.  
  76.  
  77. WatchAxis:
  78. GetKeyState, POV, JoyPOV ; Get position of the POV control.
  79. GetKeyState,  zaxis, JoyZ
  80. KeyToHoldDownPrev = %KeyToHoldDown%  ; Prev now holds the key that was down before (if any).
  81.  
  82. ; Some joysticks might have a smooth/continous POV rather than one in fixed increments.
  83. ; To support them all, use a range:
  84. if POV < 0   ; No angle to report
  85.     KeyToHoldDown =
  86. else if  POV between 0 and 4501
  87.     KeyToHoldDown = Alt
  88. else if POV >31499
  89.     KeyToHoldDown = Alt
  90. else                              
  91.     KeyToHoldDown =
  92. if zaxis = 100
  93.     KeyToHoldDown = Shift
  94. if KeyToHoldDown = %KeyToHoldDownPrev%  ; The correct key is already down (or no key is needed).
  95.     return  ; Do nothing.
  96.  
  97. ; Otherwise, release the previous key and press down the new key:
  98. SetKeyDelay -1  ; Avoid delays between keystrokes.
  99. if KeyToHoldDownPrev   ; There is a previous key to release.
  100.     Send, {%KeyToHoldDownPrev% up}  ; Release it.
  101. if KeyToHoldDown   ; There is a key to press down.
  102.     Send, {%KeyToHoldDown% down}  ; Press it down.
  103. return
  104.  
  105.  
  106. WatchJoy5:
  107. GetKeyState, joy5, joy5
  108. KeyToHoldDownPrev2 = %KeyToHoldDown2%  ; Prev now holds the key that was down before (if any).
  109.  
  110. if joy5 = U   ; No angle to report
  111.     KeyToHoldDown2 =
  112. else
  113.     KeyToHoldDown2 = Ctrl
  114. if KeyToHoldDown2 = %KeyToHoldDownPrev2%  ; The correct key is already down (or no key is needed).
  115.     return  ; Do nothing.
  116.  
  117. ; Otherwise, release the previous key and press down the new key:
  118. SetKeyDelay -1  ; Avoid delays between keystrokes.
  119. if KeyToHoldDownPrev2   ; There is a previous key to release.
  120.     Send, {%KeyToHoldDownPrev2% up}  ; Release it.
  121. if KeyToHoldDown2   ; There is a key to press down.
  122.     Send, {%KeyToHoldDown2% down}  ; Press it down.
  123. return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement