Jump to content
  • Advertisement
Sign in to follow this  
DividedByZero

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

Any advice would be awesome.

Thanks in advance.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
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.

Share this post


Link to post
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!