litlmike Posted December 9, 2017 Share Posted December 9, 2017 Func _DoOneSequence($iNumOfTimes = 1) Local $bIsSettingsButtonShowing For $eCC = 1 To $iNumOfTimes $bIsSettingsButtonShowing = _WaitForTheSettingsButtonToAppear() If $bIsSettingsButtonShowing = 1 Then _Main() EndIf Next EndFunc ;==>_DoOneSequence Func _WaitForTheSettingsButtonToAppear() Local $iSettingsButtonFound _ShowScreen() Local $sColor = 0xDEF4FB $aColorFound = PixelSearch(200, 105, 228, 133, $sColor, 75) If IsArray($aColorFound) Then ConsoleWrite("Settings Button Found" & @CRLF) Return $iSettingsButtonFound = 1 Else ConsoleWrite("Settings Button NOT Found" & @CRLF) Sleep(5555) _WaitForTheSettingsButtonToAppear() EndIf EndFunc ;==>_WaitForTheSettingsButtonToAppear There's something I am not understanding about the recursive steps here. If I keep the recursion here (after the "Else"), then $bIsSettingsButtonShowing = _WaitForTheSettingsButtonToAppear(), never equals 1. Even though the Return sets it to 1. If I remove the Else, then $bIsSettingsButtonShowing = _WaitForTheSettingsButtonToAppear() will set to 1. Is there something I am doing wrong here? Thanks for the help! _ArrayPermute()_ArrayUnique()Excel.au3 UDF Link to comment Share on other sites More sharing options...
jchd Posted December 9, 2017 Share Posted December 9, 2017 The value of your Return statement is "$iSettingsButtonFound = 1", which is parsed as a condition, testing whether $iSettingsButtonFound has value 1 or not. Since it's clear that the condition is never met, it evaluates to False. So you return the boolean value False. You want just "Return 1". But I don't understand why you think recursion is needed here. I believe you just need a single loop, not two functions with one using recursion. Which program do you automate? There may exist a cleaner way to achieve your goal. litlmike 1 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
RTFC Posted December 9, 2017 Share Posted December 9, 2017 (edited) Func _DoOneSequence($iNumOfTimes = 1) For $eCC = 1 To $iNumOfTimes If _WaitForTheSettingsButtonToAppear()=1 Then _Main() Next EndFunc ;==>_DoOneSequence Func _WaitForTheSettingsButtonToAppear() _ShowScreen() Local $sColor = 0xDEF4FB $aColorFound = PixelSearch(200, 105, 228, 133, $sColor, 75) If IsArray($aColorFound) Then ConsoleWrite("Settings Button Found" & @CRLF) Return 1 EndIf ConsoleWrite("Settings Button NOT Found" & @CRLF) Sleep(5555) Return _WaitForTheSettingsButtonToAppear() EndFunc ;==>_WaitForTheSettingsButtonToAppear or Func _DoOneSequence($iNumOfTimes = 1) For $eCC = 1 To $iNumOfTimes _WaitForTheSettingsButtonToAppear() _Main() Next EndFunc ;==>_DoOneSequence Func _WaitForTheSettingsButtonToAppear() _ShowScreen() $aColorFound = PixelSearch(200, 105, 228, 133, 0xDEF4FB, 75) If IsArray($aColorFound) Then ConsoleWrite("Settings Button Found" & @CRLF) Return EndIf ConsoleWrite("Settings Button NOT Found" & @CRLF) Sleep(5555) _WaitForTheSettingsButtonToAppear() EndFunc ;==>_WaitForTheSettingsButtonToAppear Edited December 9, 2017 by RTFC litlmike 1 My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O Link to comment Share on other sites More sharing options...
litlmike Posted December 10, 2017 Author Share Posted December 10, 2017 On 12/9/2017 at 1:56 AM, jchd said: The value of your Return statement is "$iSettingsButtonFound = 1", which is parsed as a condition, testing whether $iSettingsButtonFound has value 1 or not. Since it's clear that the condition is never met, it evaluates to False. So you return the boolean value False. You want just "Return 1". But I don't understand why you think recursion is needed here. I believe you just need a single loop, not two functions with one using recursion. Which program do you automate? There may exist a cleaner way to achieve your goal. Wow, I feel really dumb. I don't know why I didn't think of making this a loop. And thanks for the info on the Return $iVariable = 1. I changed it to this. Lmk, if you see any spots for improvements. Local $sColor = 0xDEF4FB While 1 $aColorFound = PixelSearch(200, 105, 228, 133, $sColor, 75) If IsArray($aColorFound) Then ConsoleWrite("Settings Button Found" & @CRLF) Return 1 EndIf Sleep(1111) WEnd _ArrayPermute()_ArrayUnique()Excel.au3 UDF 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