Sign in to follow this  
Followers 0
iloveauto

how to control the MsgBox?

6 posts in this topic

1)How to use AutoIt3 to send a signal to Message Box? Currently, I have one executable program that always shows up a message box with "OK"&"Cancel" button, I do not want to click the button every time and try to use AutoIt to send "OK" to it automatically. However, the send() only is useful to Window, not to message box, what should i do now?

2)is this possible to get the handle of message box in a running program?

thank you.

Share this post


Link to post
Share on other sites



1)How to use AutoIt3 to send a signal to Message Box? Currently, I have one executable program that always shows up a message box with "OK"&"Cancel" button, I do not want to click the button every time and try to use AutoIt to send "OK" to it automatically. However, the send() only is useful to Window, not to message box, what should i do now?

2)is this possible to get the handle of message box in a running program?

thank you.

If it is an AutoIt messagebox it can be setup with a timeout.

MsgBox(4096, "Test", "This box will time out in 10 seconds", 10)

If not you will have to show us some of your script so that we can see what you have tried.



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

; 1 code:This is one program to show a message box.

; Prompt the user to run the script - use a Yes/No prompt (4 - see help file)

$answer = MsgBox(4,"Message Box", "This script will active a message box with Yes/No?")

Exit

-----------------------------------------------------------------

;This is the program that sends a "Yes" to above message box

#include <GUIConstants.au3>

opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced

$handle = WinGetHandle("Message Box", "Yes")

If @error Then

MsgBox(4096, "Error", "Could not find the correct window")

Else

; Send "Yes" to the message box to close it

ControlSend("Message Box","Yes",$handle, "y")

;Send("y")

MsgBox(0,"Succ","good")

EndIf

Exit

----------------------------------------------------------

Thank you

Share this post


Link to post
Share on other sites

Change

ControlSend("Message Box","Yes",$handle, "y")

to

ControlSend($handle,"",6, "{ENTER}")



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

If you know the title of the MsgBox(), you don't need the handle: As long as these are 2 different scripts then you could do this.

If WinExists("Message Box") Then 
    ControlClick("Message Box", "&Yes", "Button1")
Else
    WinWait("Message Box")
    ControlClick("Message Box", "&Yes", "Button1")
EndIf

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Thank you, guys. you are so helpful. it works

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0