Jump to content

WinActivate by Executable Name instead of Window Title??

Recommended Posts

For years I have used WinActivate and WinWaitActive to run scripts against an application.

I use them from time to time throughout the script because other environment hazards (pop-ups, etc.) can snatch focus away from the main application.

Due to a recent change in the application, the Window title changes every time it runs an operation, and some of those occasional hazards can also change the Window's title.

There is only one instance of the application running. Is there a way that I can set focus on that application, no matter what the Window Title happens to be at that moment?? There is zero standardization per screen (hidden text) and no common threads in the window naming pattern. I just need to say, "Yes... that program. Whatever you want to call it, give it the focus."

Thank you for what I expect to be something obvious and overlooked.


Link to comment
Share on other sites

I can imagine 2 ways to skin this cat
- use _WinAPI_EnumProcessWindows to get the visible window associated to the process
- use a regex in the 'title' param of the WinActivate, this allows changes in the title and could work as long as there is a constant part in the title

Link to comment
Share on other sites

For your second solution, I used to deal with window title changes with WinTitleMatchMode ... but there is no longer any constant. (That is actually the change in the target application - the loss of a constant in the title.)

I am not familiar with have not explored "_WinAPI_EnumProcessWindows" ... I will go and quick study now. Thank you for the direction to look!





Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...