Back to a Simple Box…
Important Commands to Note:
Gui, Add, Checkbox, Variable4UserInput*, TextToDisplay
* Stored variable is 1 if checked, 0 if unchecked
This is a continuation of How to Make a User Interface except this is the part where the variables actually make something happen. Start off with a simple GUI, like this:
Now Add the IF/ELSE
When the user presses OK, the program should look at the user input and think:
1. If English is checked, I should say Hello.
2. If Spanish is checked, I should say Hola.
3. If the lazy bastards didn’t check anything, I should say something anyway.
Note that both checkbox variables start with a v, but inside the IF/ELSE the v is not needed. Actually, I just tried it, and it screwed up my IF/ELSE. Don’t include the v.
For reference, the bare bones IF/ELSE code looks like this:
If ( Expression )
{
Do this
}
else if ( Expression )
{
Do this
}
else
{
Do this
}
Plugged in and translated, the IF/ELSE portion of the code should have expressions for both checkbox variables. If the user checks a box, the variable has a value of 1, so the code in between the { } will run.
If all has gone well, the code should produce this:
In Case of Errors:
Typing the brackets on the same line will give you an error message that took me approximately 30 minutes of Googling to figure out. Put each bracket on a new line if you start getting this error.
Also, the IF/ELSE code will not recognize your variables if you enclose them in %’s. The program will just go to the last MsgBox.
you finally enabled comments! nice to see an update. what would you change about autohotkey, if anything?
personally, i would make the written syntax (which you complain about) a little more like your gui boxes: not so much required punctuation! im very biased on this, obviously 🙂
LikeLike
I agree with you on the punctuation–but what I’d really like to see is easier interaction with web browsers. ComObjCreate is a hellhole.
LikeLiked by 1 person