Advertisement
Guest User

Untitled

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