Jump to content

Getting WinActiveState to close dialog box


 Share

Recommended Posts

Using AutoIT to start an executable which installs a program, which in the very end pops up with a dialog box asking whether to reboot computer now or not.

No matter how I do it, I cannot get the scrip to work, and I am at the state where I think my brain starts to run in loops.

The first script:

Run("\\fileserver\Setup.EXE /S")

WinWaitActive("Install")

Send("{TAB}")

Send("{ENTER}")

Since this did not work, I guessed it was because the dialog box comes at the end of the installation, making the script halt on the executable before it could run the WinWaitActive command.

Then I tried making it with an If argument, so now the script looks like:

If WinWaitActive("Install") then

Send("{TAB}")

Send("{ENTER}")

EndIf

Run("\\fileserver\Setup.EXE /S")

But this does not work either.

Any thoughts or recommendations?

Link to comment
Share on other sites

First do some debugging

Run("\\fileserver\Setup.EXE /S");Run is not a blocking function, so next it is waiting for window

WinWaitActive("Install");is that the whole name of the window, are there others with same name

Msgbox(0,"","We got here")

Is the "install" window the prompt for restart computer?

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Msgbox(0,"","We got here")

Thx JohnOne, you little extra line helped a lot, I added it to after the WinWaitActive and send commands. Now the AutoIT script executes the Setup.Exe and immediately executes the other commands, even the MsgBox command.

- So should the MsgBox command not wait until WinWaitActive was finished?

- And if so is WinWaitActive not supposed to wait indefinitely (it seems to execute immediately instead of waiting on Window/dialog box)

To clarify this is the script:

Run("\\fileserver\Setup.EXE /S")

WinWaitActive("Install")

Send("{TAB}")

Send("{ENTER}")

Msgbox(0,"","We got here")

Regarding the window. There are no other windows named Install. I have triple checked the name with AutoItInfo, even tried to call the windows with Class name.

Posted Image

Link to comment
Share on other sites

WinWaitActive waits indefinately, unless you pass it a timeout paramater.

I would try adding a small sleep into your code after WinWaitActive

But first, determine if the window is actually accepting simulated key strokes.

With the window already exists, try the tab and enter code.

WinActivate("Install")

Sleep(100)

Send("{TAB}")

Send("{ENTER}")

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Okay. I managed to test more today.

Yes the box accepts input.

Tried a simplified troubleshooting. I activated the software install manual, and when the window popped up, then ran script which looked for install window and send the input, and this worked.

So either there must be a hidden window named install (other visible windows pops up during install, though not any of them are named Install), or something else which triggers the commands prematurely.

I will try other options tomorrow, e.g. matching against window content.

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...