viewpoint-particle

Author Topic: Identify the application behind the dialog  (Read 252 times)

gibberish

  • Newbie
  • *
  • Posts: 13
Identify the application behind the dialog
« on: July 31, 2018, 08:06:23 am »
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

  • Tech Support
  • *****
  • Posts: 2625
    • WinBatch
Re: Identify the application behind the dialog
« Reply #1 on: July 31, 2018, 11:40:14 am »
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.
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


td

  • Tech Support
  • *****
  • Posts: 2625
    • WinBatch
Re: Identify the application behind the dialog
« Reply #2 on: July 31, 2018, 01:34:28 pm »
Correction.  WinExeName will return the name of the exe responsible for the creation of the "Find" dialog.
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


gibberish

  • Newbie
  • *
  • Posts: 13
Re: Identify the application behind the dialog
« Reply #3 on: August 02, 2018, 06:20:31 am »
That worked perfectly - thanks very much Tony.