Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Requires AutoHotkey v2.0
- #SingleInstance
- SetKeyDelay 0, 0
- A_HotkeyInterval := 0
- SetKeyDelay -1, 0
- SendMode "event"
- CoordMode "tooltip", "screen"
- keyNames := ["1", "2", "3", "4", "5"] ; action key binds
- keys := [0,0,0,0,0]
- lastKeys := [0,0,0,0,0]
- inputs := [0,0,0,0,0]
- curAk := 0
- newAk := 0
- loop keyNames.length {
- Hotkey "*" keyNames[A_index], nop
- }
- nop(thishotkey) {
- return
- }
- SetTimer(updateKeys, 1)
- #SuspendExempt 1
- !X::ExitApp
- !R::Reload
- !P:: {
- Suspend
- Pause
- }
- updateKeys() {
- global
- getInputs
- updateAk
- }
- getInputs() {
- global
- loop keyNames.length {
- i := A_index
- lastKeys[i] := keys[i]
- state := GetKeyState(keyNames[i], "P")
- keys[i] := state
- inputs[i] := state
- if keys[i] && !lastKeys[i]
- inputs[i] := 2
- else if !keys[i] && lastKeys[i]
- inputs[i] := -1
- }
- }
- updateAk() {
- global
- loop inputs.length {
- if inputs[A_index] == 2
- newAk := A_index
- }
- loop inputs.length {
- if inputs[A_index] == -1 && curAk == A_index {
- curAk := 0
- loop inputs.length {
- if inputs[A_index] > 0
- newAk := A_index
- }
- if newAk == 0
- send keyNames[5]
- }
- }
- if newAk > 0 {
- send keyNames[newAk]
- curAk := newAk
- newAk := 0
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement