I’m often asked how to make a macro behave differently based on certain criteria.
The power and flexibility of Macro Scheduler makes this an easy task.
There are hundreds of different reasons you might want to do this. Maybe it’s dependent on :
- The answer to a question.
- The success/failure of an operation.
- The contents of a file.
- If a file or folder exists.
- If a certain mathematical goal is reached (e.g. if>count=100).
- If a certain image is visible on the screen.
- If the value of a cell in an Excel spreadsheet matches your requirement.
- If an email was/wasn’t successfully sent.
- If a value on a web page matches your criteria.
- The day/date/time or year
That’s just a handful of the many hundreds of variables we can check, but the basic rules of IF, Else, and Endif are always the same.
Let’s use asking a simple yes/no question as an example. We simply tell the macro something like this:
Ask a yes/no question
If the answer is yes
Then do this
If the answer is no
Then do that
It’s that simple! So, how do we put that into simple Macro Scheduler language? Here’s how :
//ask a yes/no question
Ask>Do you like brussel sprouts?,question
//depending on the answer given, the macro will execute *one* of the two lines below, then continue on with the rest of the script
If>%question%=YES
MessageModal>I agree, but let's keep it our secret
Else
MessageModal>Right. They're ghastly
Endif
//you can abbreviate messagemodal to mdl
mdl>OK, on with the rest of this script.
Without all the comments :
Ask>Do you like brussel sprouts?,question
If>%question%=YES
MessageModal>I agree, but let's keep it our secret
Else
MessageModal>Right. They're ghastly
Endif
mdl>OK, on with the rest of this script.
So, in short, we are doing this :
If>your condition is/isn't met
//do this
//or else
Else
//do that
Endif
“Else”, is optional. If you don’t need an “else”, just leave it out. All you need is the If and Endif. This is for if we just need to tell a macro to perform a certain action based on your criteria, but not an alternative action if the criteria is not met.
If>your condition is met
//This line only executes if the condition is met, otherwise it's ignored
Endif
Questions? Reply to this thread. Our support team and our community are always happy to help.