Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #SingleInstance Force
- #InstallKeybdHook
- SendMode Input
- global altKeys := {"foo" : "bar"
- , "a":{"``":["α"]}
- , "b":{"``":["β"]}
- , "d":{"``":["Δ"]}
- , "e":{"``":["ε", "∈"]}
- , "i":{"``":["ᵢ"]}
- , "k":{"``":["κ"]}
- , "l":{"``":["λ"]}
- , "o":{"``":["θ", "φ", "°"]}
- , "p":{"``":["ρ"]}
- , "r":{"``":["Γ", "ℝ"]}
- , "s":{"``":["σ", "Σ"]}
- , "t":{"``":["τ"]}
- , "u":{"``":["μ"]}
- , "w":{"``":["ω"]}
- , "x":{"``":["χ"]}
- , "y":{"``":["γ"]}
- , "z":{"``":["ℤ"]}
- , "=":{"``":["≈", "≠", "≡"]}
- , "<":{"``":["≤"]}
- , ">":{"``":["≥"]}
- , "~":{"``":["∝"]}
- , "+":{"``":["±", "⊕"]}
- , "-":{"``":["∓"]}
- , "*":{"``":["⋅", "⨯"]}
- , "/":{"``":["√", "∛"]}
- , "0":{"``":["∅"]}
- , "1":{"``":["¹"]}
- , "2":{"``":["²"]}
- , "3":{"``":["³"]}
- , "4":{"``":["⁴"]}
- , "8":{"``":["∞"]}
- , "_":{"``":["⌊⌋"]}
- , "'":{"``":["′", "″", "‴"]}
- , ".":{"``":["…"]} }
- global InvisibleKeys := "{LControl}{RControl}{LAlt}{RAlt}{LShift}{RShift}{LWin}{RWin}{AppsKey}{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}{Left}{Right}{Up}{Down}{Home}{End}{PgUp}{PgDn}{Del}{Ins}{BS}{CapsLock}{NumLock}{PrintScreen}"
- ;TODO : define a function to loop through all cycle keys in altKeys.
- cak := Func("CycleAltKeys")
- Hotkey ``, %cak% ; how the hell do I inline this?
- CycleAltKeys() {
- Hotkey %A_ThisHotkey%, Off
- if (altKeys.HasKey(A_PriorKey) and altKeys[A_PriorKey].HasKey(A_ThisHotkey)) {
- Keys := altKeys[A_PriorKey][A_ThisHotkey].Clone()
- }
- else {
- Send % A_ThisHotkey
- Hotkey %A_ThisHotkey%, On
- return
- }
- Keys.InsertAt(1, A_PriorKey)
- count := 0
- LastKey := A_ThisHotkey
- while (LastKey = A_ThisHotkey) {
- Send % "{Backspace " . StrLen(Keys[count+1]) . "}"
- ModIncrement(count, Keys.MaxIndex())
- Send % Keys[count+1]
- Input LastKey, L1, %InvisibleKeys%
- }
- { ; Sends the last key press when it isn't for cycling.
- ExitKey := InStr(ErrorLevel, ":") ? StrSplit(ErrorLevel, ":")[2] : ErrorLevel
- if ExitKey = "LControl"
- { Send {LControl Down}
- } else if ExitKey = "RControl"
- { Send {RControl Down}
- } else if ExitKey = "LAlt"
- { Send {LAlt Down}
- } else if ExitKey = "RAlt"
- { Send {RAlt Down}
- } else if ExitKey = "LShift"
- { Send {LShift Down}
- } else if ExitKey = "RShift"
- { Send {RShift Down}
- } else if ExitKey = "Timeout"
- { throw Exception("Shouldn't go here: " . %ErrorLevel%)
- } else if ExitKey = "Max"
- { Send % LastKey
- } else if ExitKey = "Match"
- { throw Exception("Shouldn't go here: " . %ErrorLevel%)
- } else
- { Send {Backspace}
- }
- }
- Hotkey %A_ThisHotkey%, On
- }
- ModIncrement(ByRef Num, Modulus) { ; Performs modular incrementation on Num.
- Num := Mod(Num + 1, Modulus)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement