altop Posted August 27, 2020 Posted August 27, 2020 Hi, I'm new in Autoit, just learned several days ago, and I have never learned programming language whatsoever. So this may looks stupid, but I'm just clueless right now. Below is the script I just made. Case 1 did work splendidly, as for Case 2 is where i would want the final color that i was aiming for, it just did nothing there, it didn't click.... as for "Case Else" is for every other color. or did I just messed up with the "ContinueLoop" ? And I have tried with the if else, but its a total mess, just couldn't find how it should work, pretty confused with the if else logic. Any kind of help would be much appreciated, Thank You. Func body2 () while 1 Sleep(500) Select Case 1 $red = PixelSearch (111, 264, 146, 288, 0xFF290C) if Not @error Then Sleep(200) MouseWheel("down",10) Sleep(400) EndIf ContinueLoop Case 2 $white = PixelSearch (103, 218, 141, 241, 0xFFFFFF) if Not @error Then Sleep (200) MouseMove ( 123, 243, 2) Sleep (100) MouseDown("left") Sleep (300) MouseUp("left") Sleep(100) ExitLoop EndIf case Else Sleep (300) MouseWheel ("up",10) Sleep (300) MouseWheel("down",10) Sleep (1000) ContinueLoop EndSelect WEnd
Nine Posted August 27, 2020 Posted August 27, 2020 What application are you trying to automate ? I doubt that this code will ever be robust enough. Maybe there is a better approach we could suggest if we know what you are after. “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) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Zedna Posted August 27, 2020 Posted August 27, 2020 Your Select/Case is wrong, look here: https://www.autoitscript.com/autoit3/docs/intro/lang_conditional.htm Resources UDF ResourcesEx UDF AutoIt Forum Search
altop Posted August 28, 2020 Author Posted August 28, 2020 6 hours ago, Nine said: What application are you trying to automate ? I doubt that this code will ever be robust enough. Maybe there is a better approach we could suggest if we know what you are after. Just a practical color selection things, and to test what I can do with this Autoit, the main idea is to get to "click" on white color, with the condition if i encounter a red one i need to scroll down "until" it encounter white and I can click on that, if any other color I need to scroll up and then down once only and it will turn into white that I can click on, But I also need to be at moderate speed, thus the sleep time all over the place that I experience with, 'coz I don't have any experience with any programming language at all, so I'm pretty confused as it is.
altop Posted August 28, 2020 Author Posted August 28, 2020 6 hours ago, Zedna said: Your Select/Case is wrong, look here: https://www.autoitscript.com/autoit3/docs/intro/lang_conditional.htm I've already look at that, and all the documentation in autoit help just doesn't have enough examples for me that have no experience at all on programming logics
altop Posted August 28, 2020 Author Posted August 28, 2020 I've Also experiment with if else Func body1 () while 1 Sleep(600) $color = PixelSearch (103, 218, 141, 241, 0xFFFFFF) If Not @error Then Sleep (200) MouseMove ( 123, 243, 2) Sleep (100) MouseDown("left") Sleep (300) MouseUp("left") Sleep(500) ExitLoop $color = PixelSearch (111, 264, 146, 288, 0xFF290C) ElseIf @error Then MouseWheel("down",10) Sleep(600) EndIf WEnd EndFunc well..... its working perfectly with the red and white color only what i need is for the other color other than white and red, and when it finds the other colors, it needs "only" to scroll up and then down "once" and then it will turn to white, so that it can make the click. i've tried countless variation, but it seems what i've done always mess the code..... any help ??
Zedna Posted August 28, 2020 Posted August 28, 2020 I don't understand exactly what you want, but maybe this concept/princip: expandcollapse popupFunc body2() While 1 Sleep(500) $red = PixelSearch(111, 264, 146, 288, 0xFF290C) $red_ok = Not @error If $red_ok Then Sleep(200) MouseWheel("down", 10) Sleep(400) ContinueLoop EndIf $white = PixelSearch(103, 218, 141, 241, 0xFFFFFF) $white_ok = Not @error If $white_ok Then Sleep(200) MouseMove(123, 243, 2) Sleep(100) MouseDown("left") Sleep(300) MouseUp("left") Sleep(100) ExitLoop EndIf If Not ($red_ok Or $white_ok) Then Sleep(300) MouseWheel("up", 10) Sleep(300) MouseWheel("down", 10) Sleep(1000) EndIf WEnd EndFunc ;==>body2 altop 1 Resources UDF ResourcesEx UDF AutoIt Forum Search
altop Posted August 28, 2020 Author Posted August 28, 2020 Thanks a lot , your code really helped me a lot, it worked, i didn't know that the IF ELSE could be used like this, ohh and I'm new in this kind of thing......... its really an eye opening for me what i was aiming for is : - IF the WHite color shows up i have to click on that white - if Red that shows up, i need to scroll down until I find the white color to click it, or if I encounter other color while scrolling down then i need to = scroll up once and then scroll down once, and the white color will appear and click it -if other colors shows up i need to scroll up once and then scroll down once, and the white color will appear and click it that's it. thanks.
Developers Jos Posted August 28, 2020 Developers Posted August 28, 2020 (edited) 9 hours ago, altop said: Just a practical color selection things, and to test what I can do with this Autoit, 9 hours ago, altop said: But I also need to be at moderate speed, thus the sleep time all over the place that I experience with 1 hour ago, altop said: what i was aiming for is : - IF the WHite color shows up i have to click on that white - if Red that shows up, i need to scroll down until I find the white color to click it, or if I encounter other color while scrolling down then i need to = scroll up once and then scroll down once, and the white color will appear and click it -if other colors shows up i need to scroll up once and then scroll down once, and the white color will appear and click it that's it. You are pretty explicit for somebody that "just practices". This whole thread smells as game automation, so will be (temporary) closed until @altop provides me some real information in a PM in case this is legitimate. Please start with reading our forum rules before sending that PM. Jos Edited August 28, 2020 by 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.
Recommended Posts