Make thing based on window title

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Okapi
Junior Coder
Posts: 28
Joined: Wed Dec 29, 2010 1:22 am

Make thing based on window title

Post by Okapi » Wed Dec 29, 2010 1:38 am

Hi all,

I've just discovered this great software, but here I need some help. I want a make a script like that : if the title of active window contains expression1 or expression2 or expression3, the script launches a program
This one doesn't work :

WaitWindowOpen>{("first title") or ("second title") or ("third title")}
RunProgram>C:\program.exe

Thanks

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

Post by JRL » Wed Dec 29, 2010 4:10 am

Code: Select all

//sets the active window name to variable "title"
GetActiveWindow>title,WinX,WinY
//Since we will be matching text no need to struggle with text case
//therefore set case of variable value to lower case.
LowerCase>title,title

//Use separate to determine if the text "expression1" is to be
//found within the value of variable "title".
Separate>title,expression1,res1
//If "expression1" text was found, run a program
If>res1_count>1
  Run>Program1.exe
EndIf

//same as above
Separate>title,expression2,res2
If>res2_count>1
  Run>Program2.exe
EndIf

//same as above
Separate>title,expression3,res3
If>res3_count>1
  Run>Program3.exe
EndIf


Okapi
Junior Coder
Posts: 28
Joined: Wed Dec 29, 2010 1:22 am

Post by Okapi » Wed Dec 29, 2010 2:50 pm

Not exactly what I'm looking for, I explain better what the script should do :

- When the script is launched, it never stops
- it keeps monitoring active windows titles
- whenever an active window title is "title 1" or "title 2" or "title 3", send this combination of keys : CTRL ALT a
- during 3 minutes, if that active window is being inactive then active or another window with correct title is active, do not send CTRL ALT a again.
- after 3 minutes, send this combination of keys : CTRL ALT b
- Script still continue to be on, doing its job
Last edited by Okapi on Wed Dec 29, 2010 3:20 pm, edited 1 time in total.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Dec 29, 2010 3:16 pm

Something like:

Code: Select all

Label>start
GetActiveWindow>title,x,y
If>{(%title%="title 1") OR (%title%="title 2") OR (%title%="title 3")}
  Press CTRL
  Press ALT
  Send>a
  Release ALT
  Release CTRL
  Wait>180
  Press CTRL
  Press ALT
  Send>b
  Release ALT
  Release CTRL
Endif
Wait>0.02
Goto>start
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Okapi
Junior Coder
Posts: 28
Joined: Wed Dec 29, 2010 1:22 am

Post by Okapi » Wed Dec 29, 2010 5:05 pm

@mtettmar : yes it works. Thanks for you and @JRL

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