# C++ Get HWND of another application

## Recommended Posts

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

##### Share on other sites
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).

##### Share on other sites

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?

##### Share on other sites

Anyway, worked it out. Thanks

FindWindow(NULL, "Untitled - Notepad");

##### Share on other sites
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.

##### Share on other sites
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.

## Create an account

Register a new account

1. 1
Rutin
26
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 9
• 9
• 9
• 46
• 41
• ### Forum Statistics

• Total Topics
631750
• Total Posts
3002060
×