Labels in If commands

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
R

Labels in If commands

Post by R » Wed Mar 31, 2004 2:54 pm

In MS there is some If-like commands (IfWindowOpen, IfWindowClose, and so on).
You can put two labels, the firs if the event occurs, the second if not.

I think it would be nice if MS let you leave blank the first label (ie, put the comma) so that go to label only if NOT condition.

Something like:

IfWindowsOpen>Notep*,,serr

(Then, if there is no windows open with name Notep*, it would go to label "serr")

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Wed Mar 31, 2004 3:24 pm

From the Help File:
IfWindowOpen>window_title,label_name[,false_label_name]

Checks to see if the specified window is open. If so, it causes the script to continue from the specified label without running any other lines of code in between. If a second false label is specified, execution will jump to that label if the expression resolves false. Subroutine names can also be specified
Even though first True parameter is mandatory, all you need to add is one more line to continue if True:
IfWindowOpen>notepad*,DoNotepad,NotepadDone
Label>DoNotepad
....normal continuation of script if Window Open is True
....
....
Label>NotepadDone
....
....
....
Someone else could make the same argument that script should continue here vs. jumping if Window is not open. I don't think 1 extra line is a big deal for the greater flexibility this structure provides.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts