Quantcast
Channel: AutoHotkey Community
Viewing all articles
Browse latest Browse all 579

Ask for Help (v2) • Re: Trouble creating a switch

$
0
0
Hello,

I have two suggestions.


  1. Avoid using an existing function name such as "Switch".

  2. See the documentation about global variables and their scope. Assigning a global var within a function requires declaring it as global within the function.



CODE:

#Requires AutoHotkey v2.0
swich := True
MsgBox swich

F2::output
F3::switchy

switchy() {
If !swich
Global swich := True
}

output() {
If swich {
MsgBox 'Yellow'
Global swich := False
} Else MsgBox 'Blue'
}

Statistics: Posted by mikeyww — 24 minutes ago



Viewing all articles
Browse latest Browse all 579

Trending Articles