Code: Select all
#Timer
SetTimer, PressTheKey, 9000
Return
Timer:
Send, {Numpad2}
Sleep 100
Send, {Numpad5}
Sleep, 100
Send, {Enter}
Sleep, 5000
Send, {Numpad8}
Sleep, 100
Send {NumPad5}
Sleep, 100
Send, {Enter}
Return
Code: Select all
#Timer
SetTimer, PressTheKey, 9000
Return
Timer:
Send, {Numpad2}
Sleep 100
Send, {Numpad5}
Sleep, 100
Send, {Enter}
Sleep, 5000
Send, {Numpad8}
Sleep, 100
Send {NumPad5}
Sleep, 100
Send, {Enter}
Return
Code: Select all
#Requires AutoHotkey v1.1.33
F1::
If on := !on {
SetTimer timer, 9000
SoundBeep 1500
timer()
} Else {
SetTimer timer, Off
SoundBeep 1000
}
Return
timer() {
Send {Numpad2}
Sleep 100
Send {Numpad5}
Sleep 100
Send {Enter}
Sleep 5000
Send {Numpad8}
Sleep 100
Send {NumPad5}
Sleep 100
Send {Enter}
}
Code: Select all
#Requires AutoHotkey v2.0
F1:: {
Static on := False
If on := !on {
SetTimer timer, 9000
SoundBeep 1500
timer()
} Else {
SetTimer timer, 0
SoundBeep 1000
}
}
timer() {
Send '{Numpad2}'
Sleep 100
Send '{Numpad5}'
Sleep 100
Send '{Enter}'
Sleep 5000
Send '{Numpad8}'
Sleep 100
Send '{NumPad5}'
Sleep 100
Send '{Enter}'
}
Code: Select all
#Requires AutoHotkey v1.1.33
on := False
on := (!on) ; Line 1: evaluate (NOT on), and assign to "on"
If (on) ; Line 2: If the result is neither zero nor null, execute the next statement
Send x
Code: Select all
#Requires AutoHotkey v1.1.33
If (on := (!on))
Send x
As shown, the order of operators is always followed, unless parentheses are present; parentheses always override.The word NOT is synonymous with ! except that ! has a higher precedence.
Since NOT has a higher precedence than "assign", you can now understand the line.Expression Operators (in descending precedence order)
Thank you for pointing that out. I've referenced that list so many times but never stopped at the top to realize they were ordered by precedence. (Most of the time I've reached that page via hyperlink or the index search bar and am plopped into the middle.)
Code: Select all
#Requires AutoHotkey v1.1.33
a := 2
MsgBox % StrLen(a := 45 + 99)
MsgBox % a
Code: Select all
#Requires AutoHotkey v1.1.33
a := True
If !a := !a
Send x
Code: Select all
#Requires AutoHotkey v1.1.33
a := True
If (!(a := (!a)))
Send x
Code: Select all
#Requires AutoHotkey v1.1.33
a := 3 + b := 5
MsgBox a = %a%`n`nb = %b%
Alright, I had to look up the precedence of the := and + (which I recently mastered) and found the + is higher, therefore it should resolve to a=8 and b=5... now to run the script.mikeyww wrote: ↑29 Jan 2023, 20:07Before you run the next one, take a guess at the two final values. What is the value of a? What is the value of b?
Code: Select all
#Requires AutoHotkey v1.1.33 a := 3 + b := 5 MsgBox a = %a%`n`nb = %b%
Code: Select all
#Requires AutoHotkey v2.0
Esc:: ExitApp
a := 3 + b := 5
MsgBox "a = " a "`n`n b = " b
Thank you, but that decision was based off of the question, “should I hone my v1 knowledge that might be deprecated soon or jump into v2 and quickly surpass my v1 knowledge?” It wasn’t hard to surpass my v1 knowledge!