Active window title

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
ca10c3sar
Newbie
Posts: 16
Joined: Thu Apr 13, 2017 7:36 pm

Active window title

Post by ca10c3sar » Wed Nov 29, 2017 6:09 pm

Code: Select all

Label>3

GetActiveWindow>title,x,y
If>title=Planner*
  MessageModal>BD
  Wait>10
Else
  //Something else is active
Endif

Goto>3
Endif
Specify the window name in window_title. The window_title may contain the * symbol at the end to indicate a substring match.



If the last character of the window title specified is an asterisk (*), Macro Scheduler will attempt to select the first window whose title matches the text entered exactly. If it cannot make an exact match it then looks at all windows and selects the first one it finds whose title contains the entered text (using a case-insensitive search). This solves the problem with applications such as Word or Netscape which change their titles depending on the document loaded. It is best to try to provide an exact (including case) window title to ensure the correct window is found, as many applications have multiple invisible windows with similar names. Specifying text without a trailing asterisk will force Macro Scheduler to only look for an exact match.

I searched about add a * after a word to it ignore anything after, but it dont working in my script.

Im trying make the script run only if a window named Planner be activated and focused, but everytime the window title change, example PLanner - 1, Planner - 20, so i tried Planner* but not working.

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

Re: Active window title

Post by Marcus Tettmar » Wed Nov 29, 2017 6:19 pm

Planner* will match ANY window which CONTAINS the word "planner" with in it's title regardless of case. So it will match "Planner - 1" and "Planner - 20". It will also match "1 - Planner" or "2 - Planner" or "this planner that" etc.

If you want more control you can use RegEx.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

ca10c3sar
Newbie
Posts: 16
Joined: Thu Apr 13, 2017 7:36 pm

Re: Active window title

Post by ca10c3sar » Wed Nov 29, 2017 8:17 pm

So i dont know what im doing wrong bc it dont recognize using that script.

Code: Select all

Label>3

GetActiveWindow>title,x,y
If>title=Planner*
  MessageModal>BD
  Wait>10
Else
  //Something else is active
Endif

Goto>3
Endif
I have that script running and when i set focus to my window with title "planner~~~" it doesnt send the modal message

ca10c3sar
Newbie
Posts: 16
Joined: Thu Apr 13, 2017 7:36 pm

Re: Active window title

Post by ca10c3sar » Thu Nov 30, 2017 5:51 pm

Example:
http://prntscr.com/hhdgmx

I also tried using window handle
http://prntscr.com/hhdnfp
What m doing wrong

User avatar
Djek
Pro Scripter
Posts: 147
Joined: Sat Feb 05, 2005 11:35 pm
Location: Holland
Contact:

Re: Active window title

Post by Djek » Fri Dec 01, 2017 5:55 am

hi,

just use the Debugger to see whats going wrong,
and read what Marcus is explaining to you

change your script this way:

Code: Select all

..
Label>3
GetActiveWindow>title,x,y
Length>title,Ltitle
if>Ltitle>4
  MidStr>title,1,5,strout
  If>strout=Macro
    MessageModal>BD
  endif
endif
goto>3
..
kind regards,
Djek

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