RoNYouth Posted November 25, 2019 Share Posted November 25, 2019 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 Link to comment Share on other sites More sharing options...
Nine Posted November 25, 2019 Share Posted November 25, 2019 Just loop until the next button appears checking for the control handle... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
RoNYouth Posted November 25, 2019 Author Share Posted November 25, 2019 Which function to be used sorry but i am new to AutoIT Link to comment Share on other sites More sharing options...
Annonyreeder Posted November 25, 2019 Share Posted November 25, 2019 I'm not really sure what it is you are trying to do? global $bool = false; func Objective1() ControlClick("Traffic- wizard", "&Remove","Button4") LINE 2 Sleep(3000) $bool = true ENDFUNC func Objective2() if $bool Then ControlClick("Traffic- wizard", "&Next >","Button6") LINE 4 EndIf Sleep(3000) ENDFUNC Link to comment Share on other sites More sharing options...
Nine Posted November 25, 2019 Share Posted November 25, 2019 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 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Earthshine Posted November 25, 2019 Share Posted November 25, 2019 or use my udf and the logging udf to see what is happening My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
BigDaddyO Posted November 25, 2019 Share Posted November 25, 2019 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") SkysLastChance 1 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