NoblePrimus Posted June 25, 2021 Share Posted June 25, 2021 I am writing a script to login to an application, I have several windows that pop up but I want to wait until certain controls are visible before proceeding. Right now I am using sleep to wait but I want to try and have the script run as fast as possible. Right now I am using a while command but it is not working the way I want it to. I am still fairly new at AutoIT scripting and thought there as a better way to do this. Local $hWndWt = WinWait("[CLASS:ThunderRT6MDIForm]") Local $sTitle = WinGetTitle("[ACTIVE]") ;Wait for Control While ControlGetHandle($sTitle, "", "[CLASS:ThunderRT6TextBox; INSTANCE:7]") = "" sleep(1000) WEnd If ControlCommand($sTitle, "", "[CLASS:ThunderRT6TextBox; INSTANCE:7]", "IsEnabled", "") Then Send Username and Password ControlSend($sTitle, "", "[CLASS:ThunderRT6TextBox; INSTANCE:7]", @UserName, 1) Sleep(3000) ControlSend($sTitle, "", "[CLASS:ThunderRT6TextBox; INSTANCE:6]", "Password", 1) Sleep(3000) ControlFocus($sTitle, "", "[CLASS:ThunderRT6UserControlDC; INSTANCE:18]") Sleep(3000) Send("{Enter}") EndIF I would appreciate any assistance. Link to comment Share on other sites More sharing options...
Luke94 Posted June 25, 2021 Share Posted June 25, 2021 How about a Do... Until loop? Local $hWndWt = WinWait("[CLASS:ThunderRT6MDIForm]") Local $sTitle = WinGetTitle("[ACTIVE]") ;Wait for Control ;~ While ControlGetHandle($sTitle, "", "[CLASS:ThunderRT6TextBox; INSTANCE:7]") = "" ;~ sleep(1000) ;~ WEnd Global $g_iInteger1 = 0 Do $g_iInteger1 += 1 If $g_iInteger1 >= 500 Then ; Prevent the Do.. Until.. looping forever. 500 x 10ms = 5000ms = 5 seconds ExitLoop EndIf Sleep(10) ; Sleep for 10ms Until ControlCommand($sTitle, "", "[CLASS:ThunderRT6TextBox; INSTANCE:7]", "IsEnabled", "") = 1 If ControlCommand($sTitle, "", "[CLASS:ThunderRT6TextBox; INSTANCE:7]", "IsEnabled", "") Then Send Username and Password ControlSend($sTitle, "", "[CLASS:ThunderRT6TextBox; INSTANCE:7]", @UserName, 1) Sleep(3000) ControlSend($sTitle, "", "[CLASS:ThunderRT6TextBox; INSTANCE:6]", "Password", 1) Sleep(3000) ControlFocus($sTitle, "", "[CLASS:ThunderRT6UserControlDC; INSTANCE:18]") Sleep(3000) Send("{Enter}") EndIF Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now