Jump to content
Macro Express Forums

How do I trigger other macro(s) within a macro based on if the window title changes?


Recommended Posts

I'm trying to create a macro where if the Window Title text changes to a specified exact match it will trigger a certain macro as requested.

 

For example:

 

If current window title is 222 i want to run macro named test#1, but if current window title is 333 i want to run macro named test#2 instead

 

How do I accomplish this?

Link to comment
Share on other sites

Variable Set String %WindowTitle% to topmost window title // Get window title

// You may want to parse the window title, e.g., like this:
Variable Modify String: Replace " - Mozilla Firefox" in %WindowTitle% with ""

Switch( %WindowTitle% )
Case: 222
 Macro Run: Test1
End Case

Case: 333
 Macro Run: Test2
End Case

Default Case
 Text Box Display: Window title = 222 or 333 not found!
End Case
End Switch

 

Or something like this, which may be harder to follow but may be more familiar, as it uses nested IF... ELSE instead of the SWITCH... CASE statements.

 

Variable Set String %WinTitle% to topmost program name

If Variable %WinTitle% Contains "222"
 Macro Run: Test1
Else
 If Variable %WinTitle% Contains "333"
Macro Run: Test2
 Else
 Text Box Display: Window title = 222 or 333 not found!
 End If
End If

Link to comment
Share on other sites

But Alan, your code doesn't get triggered by anything. I believe Toast wants the macros to start automatically based on the Window title.

 

There are 2 main approaches. If all your target windows share some common text, e.g. Windows Internet Explorer, then you could write a macro similar to what Alan described above, where this macro is triggered by a window title containing your common text being opened. I'd use this approach if possible.

If there's no common text, you'll have to write one macro for each target window, and have each macro triggered by opening a window containing the target text. Depending on how many windows you're attempting to control, this may get rather messy and hard to manage. But it should work.

Link to comment
Share on other sites

I find window title activation in MEP is iffy. It tends to be most reliable when windows gain focus, and less reliable when windows open or close. When it does work, there can be long delays before the command is activated.

 

I think the feature worked better in ME3.

 

I don't know a solution. I suspect conflicts with other software may be a factor... still testing that theory!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...