Jump to content

how to control the MsgBox?


 Share

Recommended Posts

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.

Link to comment
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.


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

Link to comment
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

Link to comment
Share on other sites

Change

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

to

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


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

Link to comment
Share on other sites

  • Moderators

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

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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...