Sign in to follow this  
Followers 0
ksedran

MessageBox will not close

11 posts in this topic

Hello All,

I have a fairly simple script that runs a restore process on a daily basis.

The script works fine on all the button clicks throughout the process.

The problem arises on the final step when a messagebox asks for a OK or Cancel response.

The messagebox does not go away when Cancel is clicked.

Here is the script.

Run ("D:\.........")

WinWaitActive ("Database Restore", "", "3")

ControlFocus ("Database Restore", "Next", "Next")

ControlClick ("Database Restore", "Next", "Next")

WinWaitActive ("Database Restore", "Next", "Next")

ControlFocus ("Database Restore", "Next", "Next")

ControlClick ("Database Restore", "Next", "Next")

WinWaitActive ("Database Restore", "Start Restore", "Start Restore")

ControlFocus ("Database Restore", "Start Restore", "Start Restore")

ControlClick ("Database Restore", "Start Restore", "Start Restore")

WinWaitActive ("Database Restore", "Done", "Done")

ControlFocus ("Database Restore", "Done", "Done")

ControlClick ("Database Restore", "Done", "Done")

WinWaitActive ("Database Restore", "Cancel", "Cancel")

ControlFocus ("Database Restore", "Cancel", "Cancel")

ControlClick ("Database Restore", "Cancel", "Cancel")

;Finished

The OK or Cancel messagebox stays on the screen.

Thanks in advance for any help.

ksedran

Share this post


Link to post
Share on other sites



You mean the messagebox in your app, not in AutoIt. Did you try to use the AutoIt window Info tool to see what the window's name is?

No I haven't tried the window info tool.

I just assumed the name in the top bar of the message box was the name of the window.

Where is the window info tool?

I am very new to AutoIt.

Thanks.

Share this post


Link to post
Share on other sites

Start >> All Programs >> AutoIt V3 >> AutoIt Window Info


[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

Yes the window is called "Database Restore"

Any ideas?

Thanks for the quick responses BTW.

Share this post


Link to post
Share on other sites

Yes the window is called "Database Restore"

Any ideas?

Thanks for the quick responses BTW.

Yes... Use the right ControlID's, when you hold the cursor over the buttons you'll see that AutoInfo will give you the ControlID of the Control and the ClassNameNN, you can use either of those, but I doubt seriously that the ControlID or the ClassNameNN is the same as the text ... and the Button Text maybe different also as you'll see with the AutoInfo tool.

[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

Yes... Use the right ControlID's, when you hold the cursor over the buttons you'll see that AutoInfo will give you the ControlID of the Control and the ClassNameNN, you can use either of those, but I doubt seriously that the ControlID or the ClassNameNN is the same as the text ... and the Button Text maybe different also as you'll see with the AutoInfo tool.

OK I tried using the ControlID, ClassName, and Text for this simple example below:

MsgBox(0, "AutoIt Example", "Test")

WinWaitActive("AutoIt Example", "Button1", "Button1")

ControlFocus("AutoIt Example", "Button1", "Button1")

ControlClick("AutoIt Example", "Button1", "Button1")

The info window described the Window Details as "AutoIt Example"

The ControlID as "2"

The ClassNameNN as "Button1"

and the Text as "OK"

Shouldn't this pop up the message box, then close it?

The messagebox doesn't close.

Share this post


Link to post
Share on other sites

No, again, read what each of the control function parameters are asking for:

ControlClick('Title Of Window', 'Text of Control', 'ControlID or ClassNameNN')

'Button1' is not the "Text" of the control is it... looks like it's "OK" to me... put that in there and then try (PS... When using Control Commands you don't have to have the window Active, you could change that to WinWait('Auotit example')... You have too many parameters for it anyway (there's only 2, you have 3).


[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

That code will never work, anyway. MsgBox() blocks AutoIt from continuing. Even when you do work out the correct parameters, the rest of the code will not run until the MsgBox() is dismissed - by you.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

That code will never work, anyway. MsgBox() blocks AutoIt from continuing. Even when you do work out the correct parameters, the rest of the code will not run until the MsgBox() is dismissed - by you.

:whistle:, I never even saw the MsgBox() ... Almost didn't see the WinWaitActive() because I was just looking at the control functions. Edited by SmOke_N

[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

No, again, read what each of the control function parameters are asking for:

ControlClick('Title Of Window', 'Text of Control', 'ControlID or ClassNameNN')

'Button1' is not the "Text" of the control is it... looks like it's "OK" to me... put that in there and then try (PS... When using Control Commands you don't have to have the window Active, you could change that to WinWait('Auotit example')... You have too many parameters for it anyway (there's only 2, you have 3).

Thanks for all your help SmOke_N.

I got my little test script working, hopefully it works on the real one now.

Thanks again!!

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