473,383 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Accept and Close a window using the window handle

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
4 8049
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Irvin Amoraal | last post by:
Process: I have a form which uploads a file from client to server written in PHP. When the user presses the submit button, I use the "onSubmit" event to execute javascript to open a child window...
6
by: chon | last post by:
I have an ASP page that is sent a file location as a parameter. It opens this file, loads the ADODB.Stream object and does a binary write to the page forcing the download dialog to appear. This...
5
by: Blatwurst | last post by:
I'm trying to implement a simple server in C#. I want to do the classic thing of spinning off a thread that just blocks in a Socket.Accept() call until a request comes in. At that point, the...
0
by: GrantS | last post by:
I need urgent help. Done OK for a newbie getting automation of Windows Messenger into a Winform C# app but have three problems that I urgently need pointers to. Point 1 and 2 are the same issue, I...
5
by: GEL | last post by:
Hi, I want to open a new browser window, let the user use that window for several minutes, and when they close, I'd like to change the page displayed in the original window. According to...
6
by: Ashish | last post by:
It might be basics for many but I never gave attention on this before. Steps: Add 2 forms (Form1/Form2) in application. Create a object in Form1 for Form2. Form2 f2 = new Form2(); //line...
7
by: Paul | last post by:
Hi I have a web application that has a log off selection, just redirects the browser to a form with a label displaying you are loging off. In part of the application I open a new window and was...
14
by: Paul | last post by:
Hi I have 2 functions in java script, one opens a second window-this works, the other is supposed to close this second window, does not seem to be working. Just wondering if anyone had any ideas....
1
by: kash123 | last post by:
Hi All, I have written an application, a part of which, in the application, is a socket server programe accepting connection requests from socket clients. My server code typically contains, ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.