Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to monitor for new window then have it press OK button 1

Status
Not open for further replies.

visualJay

Programmer
Jun 14, 2001
57
US
Need to be able to watch to see if a new window opens and then have my program press that windows OK or Cancel Button.
Any suggestions.
 
Is this window in your program or another one?
Todd Norris
Hope this helps !
 
The Window I Need to watch for Is an Error Window that is from another program. This window has an ok button that I need to press then as soon as it closes the NT Dr.Watson Error window opens and I need to be able to press its cancel button then restart the program.
 
VisualJay:

What you need to do is implement some sort of system wide hook that looks for window creation messages:


This is one example.

When you intercept a WM_CREATE message, take the hWnd of the created window, and use the API call GetClassName to find out the class of the window.

If this is the window you are looking for, then use the FindWindowEX api call to find the handle of the command button on the form you want to click, and use SendMessage API to send it WM_MOUSEDOWN then WM_MOUSEUP.

This should do it.

--NipsMG s-)
 
I have downloaded and looked at the code. This is almost perfect.

But the error window from this program I need to press the cancel button on does not have a caption name and does not appear in the taskbar when it comes up. How do I get Information from windows like this?
 
next time the Error window comes up on your system... run spy++ (it's in the Microsoft Visual Studio 6 tools).

Look for the error window in this list..

Expand the tree, and find out the class name of the 2 command buttons.

You can then find these using FindWindowEX and sending vbNullString for the window caption)
--NipsMG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top