By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,526 Members | 1,895 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,526 IT Pros & Developers. It's quick & easy.

Accept and Close a window using the window handle

P: n/a
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).
Nov 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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/de...ClassTopic.asp

Brendan
"trinity" wrote:
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).

Nov 17 '05 #2

P: n/a
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?

"Brendan Grant" wrote:
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/de...ClassTopic.asp

Brendan
"trinity" wrote:
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).

Nov 17 '05 #3

P: n/a
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

"trinity" wrote:
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?

"Brendan Grant" wrote:
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/de...ClassTopic.asp

Brendan
"trinity" wrote:
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).

Nov 17 '05 #4

P: n/a
Thanks Brendan

"Brendan Grant" wrote:
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

"trinity" wrote:
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?

"Brendan Grant" wrote:
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/de...ClassTopic.asp

Brendan
"trinity" wrote:

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

Nov 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.