Advertisement
Guest User

Untitled

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