Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #NoEnv
- #MaxHotkeysPerInterval 99000000
- #HotkeyInterval 99000000
- #KeyHistory 0
- ListLines Off
- Process, Priority, , H
- SetBatchLines, -1
- SetKeyDelay, -1, -1
- SetMouseDelay, -1
- SetDefaultMouseSpeed, 0
- SetWinDelay, -1
- SetControlDelay, -1
- SetTimer, WatchAxis, 5
- SetTimer, WatchJoy5, 5
- keys = 1,2,3,4,5,6,7,8,9,0,= ; key-names/scan-codes to accelarate
- Loop Parse, keys, `,
- Hotkey *%A_LoopField%, KEY
- return
- ~Pause::suspend
- KEY:
- StringTrimLeft key, A_ThisHotKey, 1
- t := 0.1 ; initial delay [seconds]
- ctrlkey := GetKeyState("Ctrl")
- shiftkey := GetKeyState("Shift")
- altkey := GetKeyState("Alt")
- if shiftkey {
- while shiftkey {
- Send +{%key%}
- KeyWait %key%, T%t%
- If ErrorLevel = 0
- Break
- t := 0.1 ; delay *= 1, while delay > 0.2
- shiftkey := GetKeyState("Shift")
- }
- KeyWait %key%
- return
- }
- else if ctrlkey {
- while ctrlkey {
- if ((GetKeyState("4", "P")) || (GetKeyState("5", "P")) || GetKeyState("6", "P")) {
- Send ^{%key%}
- Break
- }
- Send ^{%key%}
- KeyWait %key%, T%t%
- If ErrorLevel = 0
- Break
- t := 0.1 ; delay *= 1, while delay > 0.2
- ctrlkey := GetKeyState("Ctrl")
- }
- KeyWait %key%
- return
- }
- else if altkey {
- while altkey {
- Send !{%key%}
- KeyWait %key%, T%t%
- If ErrorLevel = 0
- Break
- t := 0.1 ; delay *= 1, while delay > 0.2
- altkey := GetKeyState("Alt")
- }
- KeyWait %key%
- return
- }
- else if not (shiftkey || altkey || ctrlkey) {
- while not (shiftkey || altkey || ctrlkey) {
- Send {%key%}
- KeyWait %key%, T%t%
- If ErrorLevel = 0
- Break
- t := 0.1 ; delay *= 1, while delay > 0.2
- shiftkey := GetKeyState("Shift")
- ctrlkey := GetKeyState("Ctrl")
- altkey := GetKeyState("Alt")
- }
- KeyWait %key%
- return
- }
- return
- WatchAxis:
- GetKeyState, POV, JoyPOV ; Get position of the POV control.
- GetKeyState, zaxis, JoyZ
- KeyToHoldDownPrev = %KeyToHoldDown% ; Prev now holds the key that was down before (if any).
- ; Some joysticks might have a smooth/continous POV rather than one in fixed increments.
- ; To support them all, use a range:
- if POV < 0 ; No angle to report
- KeyToHoldDown =
- else if POV between 0 and 4501
- KeyToHoldDown = Alt
- else if POV >31499
- KeyToHoldDown = Alt
- else
- KeyToHoldDown =
- if zaxis = 100
- KeyToHoldDown = Shift
- if KeyToHoldDown = %KeyToHoldDownPrev% ; The correct key is already down (or no key is needed).
- return ; Do nothing.
- ; Otherwise, release the previous key and press down the new key:
- SetKeyDelay -1 ; Avoid delays between keystrokes.
- if KeyToHoldDownPrev ; There is a previous key to release.
- Send, {%KeyToHoldDownPrev% up} ; Release it.
- if KeyToHoldDown ; There is a key to press down.
- Send, {%KeyToHoldDown% down} ; Press it down.
- return
- WatchJoy5:
- GetKeyState, joy5, joy5
- KeyToHoldDownPrev2 = %KeyToHoldDown2% ; Prev now holds the key that was down before (if any).
- if joy5 = U ; No angle to report
- KeyToHoldDown2 =
- else
- KeyToHoldDown2 = Ctrl
- if KeyToHoldDown2 = %KeyToHoldDownPrev2% ; The correct key is already down (or no key is needed).
- return ; Do nothing.
- ; Otherwise, release the previous key and press down the new key:
- SetKeyDelay -1 ; Avoid delays between keystrokes.
- if KeyToHoldDownPrev2 ; There is a previous key to release.
- Send, {%KeyToHoldDownPrev2% up} ; Release it.
- if KeyToHoldDown2 ; There is a key to press down.
- Send, {%KeyToHoldDown2% down} ; Press it down.
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement