Identify the application behind the dialog

Started by gibberish, July 31, 2018, 08:06:23 AM

Previous topic - Next topic

gibberish

When I move from my home dual-monitor config to my office dual-monitor config, (due to different monitor resolution pairs) the Find dialog for Excel VBA IDE tends to appear way above the top of the screen (not visible). So I wrote a simple WinBatch routine to watch for the Find dialog and reposition it where I want. Works great - thank you WinBatch.

The problem is that this script also repositions ANY window whose name is "~Find". So there must be a way to identify which application the Find window belongs to and only reposition the dialog if it is the Excel VBA Find dialog.

How would you recommend that I can identify the parent application for the Find dialog?

td

There are multiple approaches to this problem.   Identifying the exe is not without issue because you could have multiple Find dialogs created by Excel when multiple instances of Excel are running.  If choose the exe name approach, you can use the WinExeName function to get the name.  However, for this to work you would likely need to use Control Manager's cWndInfo function to identify the parent (owner) window of your dialog because WinExecName only works on top-level windows.

You could also use RoboScripter to create a script snippet for identifying the window by means other than its partial window name.   Generally, this approach works fairly well but it has its own set of limitations and is not always viable.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

Correction.  WinExeName will return the name of the exe responsible for the creation of the "Find" dialog.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

gibberish

That worked perfectly - thanks very much Tony.