Code: Select all
*v::
; Toggle this hotkey. The label 'SendV' will be run every 100 ms. The 'Toggle' funtion returns 1 if the current
; hotkey was turned on, and 0 if the current hotkey was turned off.
x := Toggle(A_ThisHotkey, "SendV", 100)
if (x = 1)
ToolTip, Blah
else
Tooltip
return
SendV:
Send ____
return
*c::
if (Toggle(A_ThisHotkey, "SendC", 200) = 1)
ToolTip, Blah 2
else
Tooltip
return
SendC:
Send ----
return
; This function will toggle the key passed to it (NewKey) and will turn off the other toggle that is currently active
; if one exists.
Toggle(NewKey, NewLabel, NewInterval)
{
; Saves the currently active toggle key
static ActiveToggleKey := ""
; Saves the currently active label
static ActiveLabel := ""
; if 'ActiveToggleKey' is not blank, then it needs to be turned off
if (ActiveToggleKey != "")
{
; Turn off the active timer
SetTimer, % ActiveLabel, Off
}
; If 'NewKey' is currently active then clear the 'active' variables and return 0 to indicate that it was turned off
if (NewKey = ActiveToggleKey)
{
; Clear the saved active toggle key and label
ActiveToggleKey := ""
ActiveLabel := ""
; Return 0 to indicate that the current label was turned off
return 0
}
; else turn on the new toggle
else
{
; Turn on the new timer
SetTimer, % NewLabel, % NewInterval
; Update the active toggle key and label
ActiveToggleKey := NewKey
ActiveLabel := NewLabel
; Return 1 to indicate that the new label was turned on
return 1
}
}
Edit: typo