Accept and Close a window using the window handle

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am wondering if it is possible to accept and close the active window using
its handle.

I already have the handle using getActiveWindow(). I need to be able to
click on the "yes" button to close the window. Is this possible? and if it
is, how do I do it?
(The "no" button is selected by default).
 
In order to do so, you would need to know the button’s ID so that you could
send a message to the parent window, instructing it to click it.

One other option, if you are very sure about the default of which button is
selected and know that it is on top... you could use SendKeys.Send() to send
a couple of keystrokes, from your application to the dialog.

For instance, send a left arrow key to select the button, followed by a
space key to press it. You can find more info on SendKeys at:
http://msdn.microsoft.com/library/d...frlrfSystemWindowsFormsSendKeysClassTopic.asp

Brendan
 
Unfortunately I do not know the button's ID. Is there a way to get a list of
the elements from the parent window, using only the handle?
 
Unfortunately not that I know if. We recently had a similar issue where I
work where needed an very basic application to sit on top of a much larger
and more complicated one in order to respond to basic inputs and trigger the
bigger app to do things... long story short, we had to break out the source
code for the big app to get it’s ID’s and then have the small one call them.
As you do not have that option... SendKeys may be your best route.

Brendan
 
Thanks Brendan

Brendan Grant said:
Unfortunately not that I know if. We recently had a similar issue where I
work where needed an very basic application to sit on top of a much larger
and more complicated one in order to respond to basic inputs and trigger the
bigger app to do things... long story short, we had to break out the source
code for the big app to get it’s ID’s and then have the small one call them.
As you do not have that option... SendKeys may be your best route.

Brendan
 
Back
Top