Jump to content
Macro Express Forums

ME 4 dynamically create Window Title triggered macro


Recommended Posts

I want to rename the captions (window titles) of certain windows as soon as the title of those windows come into view.

 

At the moment I have a macro that when I hit the hotkey activation it prompts for the new window title and changes the current focused window title to the prompted value. However, when I restart the computer it changes all those window titles back to their original value.

 

My idea was to, when the hotkey is pressed, dynamically create a macro that is activated by the original window title and then changing the title from within that macro.

 

Is this possible?

Link to comment
Share on other sites

It might be possible. Perhaps captures the current window title, revise it (or prompt the user to revise it), and save the result in a global variable that is restored the next time the macro is activated? Store the new name in a file that the macro reads when it is run?

 

Try to avoid creating a macro that modifies another by manipulating the MEP user interface. I know it's possible because I've done it, but phew!!! It was a lot of work. Although result was almost 100% reliable, it failed occasionally... and spectacularly.

Link to comment
Share on other sites

Sure. Just Repeat with Windows command and when you find the one you want, change it.

 

Also why don't you have a macro for each window title that activates by Window Title instead of HotKey? Then it would happen automatically. 

 

What command do you use to change them? I remember this from long ago, but have forgotten. 

Link to comment
Share on other sites

16 hours ago, Cory said:

Sure. Just Repeat with Windows command and when you find the one you want, change it.

--This is a workaround that I may end up having to do but it's not ideal

 

Also why don't you have a macro for each window title that activates by Window Title instead of HotKey? Then it would happen automatically. 

--This is what I want to do ultimately as it's the elegant solution, it's just that I don't know what the window titles are going to be, hence wanting to know how to create a macro like this dynamically.

 

What command do you use to change them? I remember this from long ago, but have forgotten. 

-- I couldn't actually find a command to change them so I found a 3rd party app that does it and I just pass it command line parameters

 

Link to comment
Share on other sites

17 hours ago, acantor said:

It might be possible. Perhaps captures the current window title, revise it (or prompt the user to revise it), and save the result in a global variable that is restored the next time the macro is activated? Store the new name in a file that the macro reads when it is run?

 

Try to avoid creating a macro that modifies another by manipulating the MEP user interface. I know it's possible because I've done it, but phew!!! It was a lot of work. Although result was almost 100% reliable, it failed occasionally... and spectacularly.

 

I'd love to know how to create a macro dynamically - specifically the type that activates on Window Title becoming active. Please could you share how you did it?

Link to comment
Share on other sites

It's easy to change a macro activated by hotkey into a macro that is activated by the window title. In fact, the same macro can be activated by either a hotkey, or a window title.

 

Open the script in the Macro Explorer, and go to the "Activations" tab. Click "Add" and then choose "Window Title." There are a lot of options, e.g., window gains focus or opens, partial or exact match of the title, etc. Some options are more reliable than others: for example, some people on this forum (but not all), recently noted that a trigger of a window gaining focus worked better than a trigger of a window opening.

 

When creating a macro from scratch, you can set the activation to window title as easily as you can set it to hotkey:

 

image.png.2bb65774f15840ece872b173cc230aa9.png

 

If your question is related to the code to capture the window title and rename it, perhaps you are looking for something like this?

 

Variable Set String %Title% to topmost window title
Variable Modify String: Replace "- Mozilla Firefox" in %Title% with "" // Delete "- Mozilla Firefox" by replacing it with ""
 
Variable Set String %NewTitle% to "<title>%Title%</title>"
MessageBox: New title = %NewTitle%

 

Link to comment
Share on other sites

acantor: I already suggested using window activation but the OP said he doesn't know what the window title will be. 

 

OP: I assume that the window title is so different that the partial match or wildcard option will not work. Is that correct? Can you give us some examples? Screen shots?

I'm confused. How do you know the app if every time the window appears is has a radically different window title?

 

Another thought: How about being proactive instead of reactive? Instead of launching the program and then trying to detect it, have MEP launch the program and then you can get the window title of the active window. Create a shortcut or whatever to MeProc.exe. CHeck out the help section "Command Line Parameters". 

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...