Jump to content

Recommended Posts

Posted (edited)

Hello,

I'm trying to automate an AntiVIR antivirus install; however, I ran into a problem. The install title is the same on the first 3 screens and the 2nd screen is a decompression of the files. I have tried sleep, and multiple attempts at also grabbing secondary text in the install using winwaitactive to have autoit pick up which window is currently displayed so I can have it select the right button. The window after has subtext I can select so as soon as I figure out this one problem I can finish the rest. I will post my code followed by the pictures of the first 3 screens.

Run("antivir_workstation_winu_en_h.exe")

WinWaitActive("Avira AntiVir Personal")
Controlclick("Avira AntiVir Personal", "Accept", "Button1")
WinWaitActive("Next", "Welcome to the setup")
Controlclick("Next", "Button2")

Posted Image

Posted Image

Posted Image

Edited by finalfx
Posted (edited)

First, I see some incongruities with the example code. Try changing the last 2 lines to read:

WinWaitActive("Avira AntiVir Personal", "Welcome to the setup")
Controlclick("Avira AntiVir Personal", "", "Button2")

Failing this, I agree with amokoura. Try using a UDF to wait for the specific control to exist. For example:

;===============================================================================
;
; Function Name:    WinWaitControlExists
; Description::     Waits for a control to exist in the active window
; Parameter(s):     $controlID = Any valid AutoIt control search parameter(s)
;           $timeoutMilliseconds = time to wait in milliseconds ( default is 2000 )
; Requirement(s):     None
; Return Value(s):  Success = handle to the control; Failure = 0 ( @error = 1 )
; Author(s):        Zach Fisher
;
;===============================================================================
;
Func WinWaitControlExists( $controlID, $timeoutMilliseconds = 2000 )
    Local $returnCode = 0
    Local $time = 0
    Local $sleepTime = 250
    while ( $returnCode <> 1 ) AND ( $time < $timeoutMilliseconds )
        $returnCode = ControlFocus( "[ACTIVE]", "", $controlID )
        $time = $time + $sleepTime
        Sleep( $sleepTime )
    wend
    if $returnCode = 0 then 
        SetError( 1 )
    Else
        $returnCode = ControlGetHandle( "[ACTIVE]", "", $controlID )
    EndIf
    return $returnCode
EndFunc

Where:

WinWaitActive("Avira AntiVir Personal")
$control = WinWaitControlExists( "[CLASS:Button;TEXT:Accept]" )
ControlClick( "[ACTIVE]", "", $control )
Edited by zfisherdrums

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
×
×
  • Create New...