Jump to content
  • Advertisement
Sign in to follow this  
fathom88

Grabing Window Handle??

This topic is 5117 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I would like to create a service to grab pop up windows and shut them down programatically. For instance, let's say Windows displays a warning message with an Re-try and Cancel button. I want the service to be able to click cancel as if a user were present. I was thinking of using FindWindow(NULL, NULL). I'm not sure if this is the best way because I would need to scan some description string and know it ahead of time. I don't want to close down a 3rd party app by mistake. Another problem is telling the window to close. I send a BN_CLICKED, but does not work. I suspect I need the actual handle to the control and not just the window. Any ideas? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by fathom88
I would like to create a service to grab pop up windows and shut them down programatically. For instance, let's say Windows displays a warning message with an Re-try and Cancel button. I want the service to be able to click cancel as if a user were present. I was thinking of using FindWindow(NULL, NULL). I'm not sure if this is the best way because I would need to scan some description string and know it ahead of time. I don't want to close down a 3rd party app by mistake. Another problem is telling the window to close. I send a BN_CLICKED, but does not work. I suspect I need the actual handle to the control and not just the window. Any ideas? Thanks.


You'd need to send a WM_COMMAND set up like a BN_CLICKED to the parent window, or else fake a mouse click on the button itself. You'd probably be better off using PostMessage() than SendMessage () since the window will be in a different process to your app. Remember that the id of the cancel button is usually IDCANCEL.

As for identifying which windows you want to cancel automatically, you can ensure it's a dialog window by checking the class - use GetClassName() to get the window class, and you the value you're looking for is "#32770" for dialog windows. It may also be worth looking at the options that are available, you can use EnumChildWindows() to determine what buttons and controls are on this dialog, and decide whether it's one you want to handle.

Share this post


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