mhpreiman
11/25/2017 - 2:37 AM

ahk toggle

Toggling part of script on/off with one keybind (Alt+R)

toggle:=False                           ;our switch

#If toggle and WinActive("ahk_class Chrome_WidgetWin_1")     ;WinActive to prohibit the script interact outside Chrome
    a::send tere
#If

!r::                                   ;Alt+R       you can replace !r with its' VK equivalent !vk52
    KeyWait, r
    (toggle:=!toggle) ? "on":"off"    ;toggle keybinds on/off
    Return

is the same as (at least seem to):

!r:: 
toggle:=!toggle

#If toggle and WinActive("ahk_class Chrome_WidgetWin_1")    
    a::send tere        
#If

Another toggle:

#MaxThreadsPerHotkey 2

CapsLock::
if (toggle := !toggle) {
    ; on
} else {
    ; off
}
return
```