ProZabijaka Posted December 18, 2022 Share Posted December 18, 2022 Hello everyone! I'm new here so I hope I won't mess anything up. Recently I started making a little script that is searching for a pixel color in defined space and then clicking the spot, there are two cases, with two different colors and I don't know how to write the script so it stops when both colors are missing. Below is my code: expandcollapse popup#include <MsgBoxConstants.au3> #include <AutoItConstants.au3> ; Odszukuje kwadracika "New" w kolorze fioletowym i naciska go Local $aCoord = PixelSearch(1930, 40, 2560, 1020, 0xCC66FF) ; Odszukuje znaczek telefonu Local $bCoord = PixelSearch(0, 0, 2559, 1059, 0xFFFF99) Local $i = 1 Switch $i Case 1 Do ;If Not @error Then ;Local $aCoord = PixelSearch(1930, 40, 2560, 1020, 0xCC66FF) Local $aCoord = PixelSearch(1930, 40, 2560, 1020, 0xCC66FF) MouseClick($MOUSE_CLICK_PRIMARY, $aCoord[0], $aCoord[1], 1) Sleep(500) Local $cCoord = PixelSearch(1930, 40, 2560, 1020, 0xFAEBFF) MouseClick($MOUSE_CLICK_PRIMARY, $cCoord[0], $cCoord[1], 1) Sleep(500) If @error Then $i = 2 EndIf Until $i = 1 Case 2 Do ;Local $bCoord = PixelSearch(1930, 40, 2560, 1020, 0xFFFF99) Local $bCoord = PixelSearch(0, 0, 2559, 1059, 0xFFFF99) MouseClick($MOUSE_CLICK_PRIMARY, $bCoord[0], $bCoord[1], 1) Sleep(500) Local $dCoord = PixelSearch(2000, 750, 2490, 950, 0xFBFF00) MouseClick($MOUSE_CLICK_PRIMARY, $dCoord[0], $dCoord[1], 1) Sleep(500) Local $fCoord = PixelSearch(2000, 750, 2490, 950, 0xACACAC) MouseClick($MOUSE_CLICK_PRIMARY, $fCoord[0], $fCoord[1], 1) Sleep(500) Local $cCoord = PixelSearch(1930, 40, 2560, 1020, 0xFAEBFF) MouseClick($MOUSE_CLICK_PRIMARY, $cCoord[0], $cCoord[1], 1) Sleep(500) If @error Then $i = 0 EndIf Until $i = 2 ;EndIf EndSwitch I will get rid of the comments when it will start working as I want it. Also I think MsgBoxConstants is not required but is the remain of a Helpfile script :D Link to comment Share on other sites More sharing options...
Nine Posted December 18, 2022 Share Posted December 18, 2022 (edited) Can I ask what is the application you are trying to automate ? Looks to me some sort of a game, right ? Plz read forum rules... Edited December 18, 2022 by Nine “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...
ProZabijaka Posted December 18, 2022 Author Share Posted December 18, 2022 2 hours ago, Nine said: Can I ask what is the application you are trying to automate ? Looks to me some sort of a game, right ? Plz read forum rules... Yes, you are right and from what I read that technically declines my request. Although if I can tell something more it is not for any score, game gave me access to something but I have to go through a lot of "popups" to receive what I actually care for, that's why I wanted to automate that. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 19, 2022 Moderators Share Posted December 19, 2022 Welcome to the AutoIt forum. Unfortunately you appear to have missed the Forum rules on your way in. Please read them now - particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked. See you soon with a legitimate question I hope. The Moderation team ProZabijaka 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts