Jump to content

Recommended Posts

Posted

    ControlClick("Traffic- wizard", "&Remove","Button4") LINE 2
    Sleep(3000)
    ControlClick("Traffic- wizard", "&Next >","Button6")     LINE 4
    Sleep(3000)

In the above code i want my code to behave in manner if Line 2 gets completed than only it should go forward to Line 4 but i font want to use Sleep as sometime application can work quickly but punting sleep means it would wait until that time. Can anyone tell me how to write session based codes in AutoIT

Posted

Try something like this (untested)

Example ()

Func Example ()
  Local $hCtrl, $iCount = 0
  While True
    $hCtrl = ControlGetHandle ("Traffic- wizard", "&Next >","Button6")
    If $hCtrl Then ExitLoop
    $iCount += 1
    If $iCount > 50 Then Return MsgBox ($MB_SYSTEMMODAL,"Error", "Unable to get control")
    Sleep (100)
  WEnd
  ControlClick("Traffic- wizard", "",$hCtrl)
EndFunc

 

Posted

I like to use this method with either IsVisible or IsEnabled depending on how the screen reacts.

it's much more coding but it's faster to run the automation.

 

$iTimer = TimerInit()
    While 1
        If ControlCommand("Traffic-wizard", "&Next", "Button6", "IsVisible", "") = 1 Then
            ExitLoop
        EndIf

        If TimerDiff($iTimer) >= 30000 Then ;What's the max time until it throws an error? 30 seconds
            MsgBox(0, "Failed", "Next screen failed to display within the allowed time")
            Exit 2
        EndIf

    WEnd
    
    ;Now ControlClick the button
    ControlClick("Traffic-wizard", "&Next >", "Button6")

 

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
  • Recently Browsing   0 members

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