if window title contains a word

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Snickers
Macro Veteran
Posts: 150
Joined: Thu Dec 09, 2004 3:01 pm
Location: Somewhere in TX

if window title contains a word

Post by Snickers » Tue Sep 11, 2007 12:46 pm

Is there a command that would allow me to do the following:
[code]

GetActiveWindow>title,X,Y

If>title contains the word "Mozzilla"
//do something
else
//do something else
endif
[/code]

User avatar
JRL
Automation Wizard
Posts: 3517
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Sep 11, 2007 12:56 pm

I like to search for text using Separate>
This will be a case sensitive search.

Code: Select all

GetActiveWindow>title,X,Y

//If>title contains the word "Mozzilla"
Separate>%title%,Mozzilla,var
If>%var_count%>1
//do something
else
//do something else
endif

Snickers
Macro Veteran
Posts: 150
Joined: Thu Dec 09, 2004 3:01 pm
Location: Somewhere in TX

Post by Snickers » Tue Sep 11, 2007 1:07 pm

Great! This works perfectly; however, i am not understanding something.

Help file says, "Also returned is the number of elements in the list, in returnvar_count."

In the code you provided, why is the var_count returning a value of 2?


EDIT: I misspelled the word "Mozilla" above; so don't be confused if the code doesn't work for you. Correct the spelling and all is well.

User avatar
JRL
Automation Wizard
Posts: 3517
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Sep 11, 2007 1:21 pm

If you separate the window title text:
Windows Scripting, Windows Macro Automation, Windows Macro Recorder - Automate your PC for Windows 9x/NT/ME/2000/XP/Vista :: View topic - if window title contains a word - Mozilla Firefox
using Mozilla as the separator you will get two variables with the values

var_1=Windows Scripting, Windows Macro Automation, Windows Macro Recorder - Automate your PC for Windows 9x/NT/ME/2000/XP/Vista :: View topic - if window title contains a word -
var_2= Firefox

also giving you a count var_count=2

Snickers
Macro Veteran
Posts: 150
Joined: Thu Dec 09, 2004 3:01 pm
Location: Somewhere in TX

Post by Snickers » Tue Sep 11, 2007 1:31 pm

Very nice! Thank you for the code snippet and the explanation.

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 » Tue Sep 11, 2007 2:54 pm

How about "Position" function?

GetActiveWindow>title,X,Y
Position>Mozilla,%title%,1,StartPos
If>%StartPos%>0,Do Something,Do Something Else
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Snickers
Macro Veteran
Posts: 150
Joined: Thu Dec 09, 2004 3:01 pm
Location: Somewhere in TX

Post by Snickers » Tue Sep 11, 2007 4:58 pm

That one is nice too, Bob. It seems to be more direct. Thank you. Those both work great!

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