scorp2k19 Posted October 3, 2019 Posted October 3, 2019 Hey guys, iv been running multiple tests to learn the While Loop completely but i have a few concerns lol sorry Here is an example of what I am trying: HotKeySet("^!x", "MyExit") While 1 If PixelSearch() ;for example: a blue color from a notification from Facebook If not (@error) then ;if pixel is found, do this until pixel is not there Else While 1 If PixelSearch() ;for example: a white color from a Gmail notification when you receive an email If not (@error) then ;if pixel is found, do this until pixel is not there Else Exitloop ;i placed this exitloop so it will go back to continue searching for the blue pixel. EndIf WEnd EndIf WEnd Func MyExit() Exit EndFunc When I try this, it doesn't return to loop 1 but I am not sure if the reason why is not going back to loop 1 is due to the ExitLoop I placed... maybe I should use something "Do, Until" instead of While?
FrancescoDiMuro Posted October 3, 2019 Posted October 3, 2019 @scorp2k19 PixelSearch() is not the solution to automate such things. Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
Developers Jos Posted October 3, 2019 Developers Posted October 3, 2019 There is NO way that posted script works so please give a proper example for us to look at or simply post the real script! Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
scorp2k19 Posted October 3, 2019 Author Posted October 3, 2019 (edited) Sorry, I was just trying to understand how it works. I will try to post a proper example when I get home. EDIT to avoid double post: Can you answer me a quick question? Whats the difference between using While 1 vs While True ? is it the same? Thanks Edited October 3, 2019 by scorp2k19
Dana Posted October 8, 2019 Posted October 8, 2019 (edited) HotKeySet("^!x", "MyExit") While 1 If PixelSearch() ;for example: a blue color from a notification from Facebook If not (@error) then ;if pixel is found, do this until pixel is not there Else While 1 If PixelSearch() ;for example: a white color from a Gmail notification when you receive an email If not (@error) then ConsoleWrite("white pixel found" & @crlf) ;if pixel is found, do this until pixel is not there Else ConsoleWrite("returning to main loop" & @crlf) Exitloop ;i placed this exitloop so it will go back to continue searching for the blue pixel. EndIf WEnd EndIf WEnd Func MyExit() Exit EndFunc This way you can see what's happening. While 1 = While True Edited October 8, 2019 by Dana
seadoggie01 Posted October 8, 2019 Posted October 8, 2019 8 minutes ago, Dana said: While 1 = While True Saying True makes so more sense and makes your code much more readable (especially to me... slightly dyslexic, I always think 0 is true). It's good practice, see: magic numbers All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types
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