Jump to content
Sign in to follow this  

Problem getting program to wait until a button appears

Recommended Posts



I am writing a script that needs to wait for a scan to complete before it can click a button "Next >" to continue on to the next page. I am completely stumped. I've tried a few different loops to no avail. The other issue is that what the button ID is the same for the cancel button that is present during the scan as the next buttons ID after the scan, which is what has stumped me.

any advice would be great.



Share this post

Link to post
Share on other sites


Can u tell me what application's button u have to check.. if u can pls provide the download link.. so that i can test it out..

[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com

Share this post

Link to post
Share on other sites

Don't use the ID. Use the TEXT to differentiate the two buttons then wait till the next button becomes enabled.

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post

Link to post
Share on other sites

I usually use winwait("title","text") For that. Theres usually text saying that the scan is complete that you can use. So the full code would be:

winactivate("title","text");I know this is redunt when using controlclick, but I still do it out of habit
controlclick("title","text","[TEXT: Next >]")

Share this post

Link to post
Share on other sites

Check out this quick example:

#include <GUIConstantsEx.au3>
$GUI = GUICreate ("", 200, 90)

$button1 = GUICtrlCreateButton ("Button 1", 20, 10, 160, 33)
GUICtrlSetState ($button1, $GUI_DISABLE)
$button2 = GUICtrlCreateButton ("Button 2", 20, 50, 160, 33)
GUISetState ()

$timer = TimerInit ()
$timerd = True

While 1
    ToolTip ("Button 1 State = " & ControlCommand ($GUI, "", "[CLASS:Button; INSTANCE:1]", "IsEnabled", ""))
    $nMsg = GUIGetMsg ()
        Case $nMsg = -3
        Case TimerDiff ($timer) >= 5000; Wait 5 seconds
            If $timerd Then
                GUICtrlSetState ($button1, $GUI_ENABLE)
                $timerd = False

Use the AutoIt Window Info tool to get the class/instance part.



Edited by BrettF

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