Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- global DoTimeout := false ; toggle
- global DefaultCursorBlinkRate := .530 ; in seconds (530ms). Windows 10 default
- global TimeoutTime := 2.5 * DefaultCursorBlinkRate
- global TimeoutString := DoTimeout ? "T" . TimeoutTime :
- }
- ; Allows the user to choose a string in KeysArray. Switching between strings is toggled by pressing the CycleKey.
- ; Despite what the name implies, strings in KeysArray can contain more than one character.
- CycleAltKeys(KeysArray, CycleKey) {
- SendInput % KeysArray[1]
- Input LastKey, %TimeoutString% L1, {BS}
- count := 0
- while LastKey = CycleKey {
- Backspaces(StrLenU(KeysArray[count + 1]))
- ModIncrement(count, KeysArray.MaxIndex())
- SendInput % KeysArray[count + 1]
- Input, LastKey, %TimeoutString% L1, {BS}
- }
- if ErrorLevel = EndKey:Backspace
- {
- SendInput {BS}
- }
- if ErrorLevel = Timeout
- {
- SendInput {Space}
- }
- else {
- SendInput % LastKey
- }
- }
- ; Sends Num amount of backspaces.
- Backspaces(Num) {
- Loop %Num% {
- SendInput {BS}
- }
- }
- ; Performs modular incrementation on Num.
- ModIncrement(ByRef Num, Modulus) {
- Num := Mod(Num + 1, Modulus)
- }
- ; Determines the length of the string Str containg escaped Unicode characters.
- StrLenU(Str) {
- return StrLen(RegExReplace(Str, "{U\+\w+}", "⨯"))
- }
- ; Allows the user to choose between "equals" (=) and "approximately equals" (≈), using just the "equals" key provided on most keyboards.
- =::CycleAltKeys(["{U+003D}", "{U+2248}"], "``")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement