473,385 Members | 1,337 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,385 software developers and data experts.

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 5264
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
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
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
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
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
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
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...
4
by: chris | last post by:
can anybody have some ideas?
2
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
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...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.