Below is an example with toggles ScrollLock and Alt-T. The ScrollLock hotkey routine checks the toggle state of ScrollLock. If it is On, create a hidden GUI window, named "ScrLk". If it is Off, destroy this invisible window. (Similarly, you can use CapsLock and NumLock.) Alt-T toggles a variable and creates/destroys another hidden window, named Alt-T. (Other non-toggle keyboard keys can be used similarly.)
These hidden windows only exist when the corresponding toggle is On, so the hotkeys after the corresponding #IfWinExist lines only work if they are turned On. (The first listed hotkey is activated if more than one toggle is On.) After the last #IfWinExist line list the hotkeys, which shall be active when no toggle condition is active.
DetectHiddenWindows On GoSub ~ScrollLock ; react to initial state ; ... further code here ; --- end of autoexecute section --- ~ScrollLock:: ; toggle by create/destroy a hidden window If GetKeyState("ScrollLock","T") Gui 1:Show, Hide, ScrLk Else Gui 1:Destroy Return !T:: ; toggle by create/destroy a hidden window AltT := !AltT If AltT Gui 2:Show, Hide, Alt-T Else Gui 2:Destroy Return #IfWinExist ScrLk ; below the HotKeys are active when CapsLock is ON !z::MsgBox ScrollLock ON ;... #IfWinExist Alt-T ; below the HotKeys are active when Alt-T toggle is ON !z::MsgBox Alt-T ON ;... #IfWinExist ; below the HotKeys are active when all toggles are Off !z::MsgBox ScrollLock/Alt-T Off ;...Edit 2006.03.07: Added comments, changed GoTo to GoSub