Get HWND of another application

Started by
5 comments, last by DividedByZero 6 years, 3 months ago

Hi Guys,

Just wondering if it is possible to get the window handle of another open application given it's window title?

The reasoning behind this is I am making an external editor for an IDE and want to inject an 'F5' to force the external IDE to make a build. The IDE doe not have any external way to trigger a build (GameMaker Studio).

Any advice would be awesome.

Thanks in advance.

Advertisement
20 minutes ago, lonewolff said:

Hi Guys,

Just wondering if it is possible to get the window handle of another open application given it's window title?

The reasoning behind this is I am making an external editor for an IDE and want to inject an 'F5' to force the external IDE to make a build. The IDE doe not have any external way to trigger a build (GameMaker Studio).

Any advice would be awesome.

Thanks in advance.

First result.

Yes, I did do a google search, thanks ;)

Isn't this talking about getting the window 'host' applications though?

In your example, the OP is talking about an application that is using his own DLL in it.

If I were to get the HWND of something like notepad.exe how would I go about that?

Anyway, worked it out. Thanks :)

FindWindow(NULL, "Untitled - Notepad");

1 minute ago, lonewolff said:

Yes, I did do a google search, thanks

Isn't this talking about getting the window 'host' applications though?

In your example, the OP is talking about an application that is using his own DLL in it.

If I were to get the HWND of something like notepad.exe how would I go about that?

Read the reply in that thread. It outlines the method and mentions the fact that you may not be dealing with a single main window. Once you can list windows that belong to a process, figure out how to go about doing that to a different process. The first logical step here would be to substitute the current process for what ever process you need. Again, first reply.

Note that there may be more than once instance of a single executable running, so you probably need to list all processes called notepad.exe, open each one and list all windows, doing your best to figure out which one is the main window. This may be trivial for notepad.exe, but not so much for something messier, like Gimp.

Just now, lonewolff said:

Anyway, worked it out. Thanks :)

 



FindWindow(NULL, "Untitled - Notepad");

 

This will only give you a valid result if the user is editing an unnamed and likely unsaved document and only if there is one instance of Notepad running.

9 minutes ago, irreversible said:

This will only give you a valid result if the user is editing an unnamed and likely unsaved document and only if there is one instance of Notepad running.

Correct.

In my case I know what the window title will be on every occasion (even if it changes). So this method works out well for me.

This topic is closed to new replies.

Advertisement