Advertisement
Guest User

Untitled

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