If you want to make this script shorter, do this:
Code: Select all
Toggle := False
;====================================
; Alt + Y
;====================================
!y::
;====================================
Toggle := !Toggle
SoundBeep(Toggle ? 1000 : 2000, Toggle ? 200 : 500)
MsgBox, % Toggle ? "its on again" : "its off"
; MsgBox(Toggle := !Toggle ? "its on again" : "its off") ; V2
Return
; Remove this function if in V2
SoundBeep(A, B) {
SoundBeep, % A, % B
}
Short and sweet version. This allows for single line ifs, which work like this (In a nutshell):
Code: Select all
; Long ways.
If Var = Value
A.Function()
Else
B.Function()
; Single line.
Random_Unneeded_Function(Var = Value ? A.Function() : B.Function())
The question mark
? is the IF, and the colon
: is the ELSE.
Short, easy, simple.