Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 8th, 2004, 10:50 PM
Authorized User
 
Join Date: Jun 2003
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default Programmatically close a message box

Hello -

I need to be able to automatically click the OK button everytime a certian message box shows up in a given windows application.

I've been reading a few articles about using the Windows API to automatically do stuff like this, but I was wondering what the best way to go about it is. Should I use the mouse_event message to move the mouse over the button and click it? Or should I send tabs and enters via the keyboard to hit the button? Or is there a way to trigger the click event on the button directly?

Also most of the API commands require the hWnd of the given window or control, how can I find that? Will it always be the same for a given button in one application (I would assume not)?

Any input would be most appreciated.

Thanks in advance,
Mike
 
Old June 10th, 2004, 06:53 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Does this do the trick?

http://p2p.wrox.com/topic.asp?TOPIC_ID=14576

Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old June 24th, 2004, 01:26 AM
Authorized User
 
Join Date: Jun 2004
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes Greg is right but .....
Why not this... :)

DoCmd.SetWarnings 0 or 1

I know both are the same but SetWarnings save space ... and easy ..too

Stay Beautiful,

Abdul Salam

There is no moving creature on Earth whose sustenance is not provided by Allah. He knows its living and its resting place,
and all that is recorded in a glorious Book. (Al-Quran)
 
Old June 25th, 2004, 05:44 PM
tnd tnd is offline
Authorized User
 
Join Date: Jun 2004
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If you are using messagebox in your code then the answer is NO. The reason is messagebox is a modal form. APIs will not work unless they are in another process.

If you want to write another program to close messagebox of a different program then start with FindWindow API call.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Message box basie Classic ASP Basics 1 September 4th, 2008 01:09 PM
close window with out message box cesemj ASP.NET 1.0 and 1.1 Basics 10 October 2nd, 2007 09:23 AM
Close box zaghmout ASP.NET 2.0 Basics 2 September 5th, 2007 03:54 AM
message box nalla ASP.NET 2.0 Professional 4 December 23rd, 2005 03:00 AM
close window with out message box nutrino ASP.NET 1.0 and 1.1 Basics 2 December 6th, 2005 04:26 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.