EvilOniLink Posted August 10, 2015 Share Posted August 10, 2015 I have a code that looks for many colors and when it finds one of them it clicks it. I would like to put all of the colors into a category or array so that I could shorten the code.Func Start() While 1 $Color1 = PixelSearch(5, 99, 1140, 725, 0xE2CC4C) $Color2 = PixelSearch(5, 99, 1140, 725, 0xE2E159) If IsArray($Color1) Then MouseClick("primary", $Color1[0], $Color1[1]) Sleep(Random(12000, 13000, 1)) ElseIf IsArray($Color2) Then MouseClick("primary", $Color2[0], $Color2[1]) Sleep(Random(12000, 13000, 1)) EndIf WEndEndFuncThis is fine for a couple of colors but if I have 20 or more colors the code gets lengthy and I'd much rather just have a collection of colors and then a command that calls all of those colors during a pixel search. for example:Local $Colors[3] = ["Color 1", "Color 2", "Color ect."]$Colors[0] = 0xE2CC4C$Colors[1] = 0xE2E159$Colors[2] = ect.Func Start() While 1 $Colors = PixelSearch(5, 99, 1140, 725, $Colors) Link to comment Share on other sites More sharing options...
Danyfirex Posted August 10, 2015 Share Posted August 10, 2015 pseduo code. array[]=[0xE2CC4C, 0xE2E159,etc] whilefor i=0 to array count -1$colorpos= PixelSearch(5, 99, 1140, 725, array[$i])if is array($colorpos) then MouseClick("primary", $colorpos[0], $colorpos[1]) Sleep(Random(12000, 13000, 1))endif$colorpos=0nextwend Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
water Posted August 10, 2015 Share Posted August 10, 2015 Can you please tell us why you need to search for 20 different colors?Pixelsearch and Mouseclick are not very reliable (depend on screen resolution and window postion) and most of the time there are more reliable ways to do what you want to do. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
EvilOniLink Posted August 10, 2015 Author Share Posted August 10, 2015 Thank you Danyfire. Water, because there are a bunch of different colors and I want to click which ever one shows up. Link to comment Share on other sites More sharing options...
water Posted August 10, 2015 Share Posted August 10, 2015 Fine, but which application do you try to automate? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
AutoBert Posted August 10, 2015 Share Posted August 10, 2015 @Water: It must be a Online-Game, serious other applications don't need a random sleep.Func Start() While 1 $Color1 = PixelSearch(5, 99, 1140, 725, 0xE2CC4C) $Color2 = PixelSearch(5, 99, 1140, 725, 0xE2E159) If IsArray($Color1) Then MouseClick("primary", $Color1[0], $Color1[1]) Sleep(Random(12000, 13000, 1)) ElseIf IsArray($Color2) Then MouseClick("primary", $Color2[0], $Color2[1]) Sleep(Random(12000, 13000, 1)) EndIf WEndEndFunc Link to comment Share on other sites More sharing options...
water Posted August 10, 2015 Share Posted August 10, 2015 OK, I'm going to report this.Maybe the OP is more willing to explain what he needs the code for when a Mod asks My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
EvilOniLink Posted August 10, 2015 Author Share Posted August 10, 2015 Go ahead and report it. I never read in the agreements that you had to tell everyone what you were doing and why. Plus I already got what I needed 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