473,487 Members | 2,474 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Q: Automaticly click ok when a message dialog appears.

Hi!

I am constructing a program that will massverify some reports.

How ever there is a message dialog comming up saying that the report is up
to date or needs change.

Is there a way to detect when this dialog appears and send a key stroke or
send a message to the button on the dialog?

I know the title of the message dialog.

Regards
Martin
Jul 11 '08 #1
2 5268
I assume the message boxes are being generated by a separate app that you
have no ability to modify?

You can do this using the Windows API. You can iterate through all the
windows with EnumWindows and EnumChildWindows and get the window text with
GetWindowText. Or you can search for the window directly with FindWindow and
FindWindowEx.

Once you have the handle to the window you can send a message to it via
SendMessage. If it's a standard dialog box, you can probably just send it
WM_KEYDOWN with a parameter of VK_ENTER.

You can find documentation on these APIs in C# on Pinvoke.net. You can also
google the functions I mentioned to find code samples.

As for getting a notification of a new message box, you could probably
create a windows event hook to do it. You can Google windows hooks to find
out more. That's probably overkill, though. I'd probably just use a timer to
have my app check for a new dialog box every 10 seconds or so.

Andrew Faust

"Martin Arvidsson, Visual Systems AB" <ma**************@vsab.netwrote in
message news:uR**************@TK2MSFTNGP03.phx.gbl...
Hi!

I am constructing a program that will massverify some reports.

How ever there is a message dialog comming up saying that the report is up
to date or needs change.

Is there a way to detect when this dialog appears and send a key stroke or
send a message to the button on the dialog?

I know the title of the message dialog.

Regards
Martin
Jul 11 '08 #2
Thank you!

That realy solved my problem.

Regards
Martin

"Andrew Faust" <an****@andrewfaust.comskrev i meddelandet
news:67**********************************@microsof t.com...
>I assume the message boxes are being generated by a separate app that you
have no ability to modify?

You can do this using the Windows API. You can iterate through all the
windows with EnumWindows and EnumChildWindows and get the window text with
GetWindowText. Or you can search for the window directly with FindWindow
and FindWindowEx.

Once you have the handle to the window you can send a message to it via
SendMessage. If it's a standard dialog box, you can probably just send it
WM_KEYDOWN with a parameter of VK_ENTER.

You can find documentation on these APIs in C# on Pinvoke.net. You can
also google the functions I mentioned to find code samples.

As for getting a notification of a new message box, you could probably
create a windows event hook to do it. You can Google windows hooks to find
out more. That's probably overkill, though. I'd probably just use a timer
to have my app check for a new dialog box every 10 seconds or so.

Andrew Faust

"Martin Arvidsson, Visual Systems AB" <ma**************@vsab.netwrote in
message news:uR**************@TK2MSFTNGP03.phx.gbl...
>Hi!

I am constructing a program that will massverify some reports.

How ever there is a message dialog comming up saying that the report is
up to date or needs change.

Is there a way to detect when this dialog appears and send a key stroke
or send a message to the button on the dialog?

I know the title of the message dialog.

Regards
Martin

Aug 11 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1783
by: Al Christoph | last post by:
I have a program that mixes wizard like behavior with random access to the various dialogs in the wizard. I do this by having each step map to a toolstripmenuitem. Users can randomly choose the...
0
1135
by: Chris Dunaway | last post by:
I successfully installed VS 2005 Professional RTM and am enjoying using it. Occaisionally I have re-compile a solution using VS2003. This solution has a setup project in it. During...
2
2673
by: Danny Wang | last post by:
HI, I have a dialog (window) with a drop-down list and an OK button. When user clicks the drop-down list, the app need to do some calculation and validation, so I put an Text_on_change event on...
2
6099
by: Mattbooty | last post by:
Hello, Not sure if anyone else has seen this bug, but I have a form where the entire form is covered with a picturebox. The picturebox has a mouseup event. I also have an open file dialog for...
1
2148
by: SrDhUS | last post by:
I get the following error when I try to add a web reference using Web Reference Dialog (VS .Net 2003) Error "The proxy settings on this computer are not configured correctly for web discovery."...
24
4464
by: John Gabriel | last post by:
CreateDialogIndirect() fires my Radio button click function without the radio button having being clicked. I am using VC++ 2003.NET. I believe this is yet another Microsoft bug. Have checked dialog...
2
4291
by: Peted | last post by:
Hi i have a circumstance where a user unzips a file, with a certain layer of directories to get to a textfile. So in any directory on the HDD they may end up with something like ...
2
1757
by: adarshyam | last post by:
hi, can anyone please tell me how to make a button click to open the save as dialog box of the browser(Firefox)... ie., if we press "Ctrl+s", save as dialog box appears, i want that to happen in...
0
7105
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7132
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7180
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7341
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4564
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3076
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
600
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
266
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.