Braste84 Posted April 14, 2023 Posted April 14, 2023 Hello. I have a problem which I don't know, how to solve at the moment. I have this progress bar As soon as it hits the area separated by the two lines, I need to press a button My problem is, that the bar is semitransparent, so the color depends on the background. It is some kind of red, when it hits the area, but not exactly the same every time. Does someone have any idea, how I can solve this problem?
Nine Posted April 14, 2023 Posted April 14, 2023 (edited) You could read the color with PixelGetColor and get the red component with _ColorGetRed. When the red value gets significantly higher, it means it has reached the area. Edited April 14, 2023 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Reveal hidden contents 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
Braste84 Posted April 14, 2023 Author Posted April 14, 2023 (edited) The problem is, PixelGetColor needs coordinates and the area changes every time. The area of the complete bar keeps the same, but the target area changes. So the question is, how do I get the pixel to check. Edited April 14, 2023 by Braste84
Braste84 Posted April 14, 2023 Author Posted April 14, 2023 (edited) I could check every pixel in the area in a loop, but i don't know, if autoit can keep up with the progress bar and I would have to save every pixel value to compare it in the following loop Edited April 14, 2023 by Braste84
Moderators Melba23 Posted April 14, 2023 Moderators Posted April 14, 2023 Braste84, Welcome to the AutoIt forum. Just what application is showing you this progress bar? M23 P.S. And just to be absolutely clear - this is the Mod team determining the legality of the thread, so everyone else please keep out. 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: Reveal hidden contents 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
Braste84 Posted April 14, 2023 Author Posted April 14, 2023 I tried searching for the area by searching for a pixel with the least distance to white in a row of pixels, which works really well $left = 1100 $y = 720 $right = 1460 ; Initialize variables for the pixel with the smallest distance to white $nearestPixelColor = 0 $nearestPixelDistance = 16777215 ; Loop through each pixel in the area For $x = $left To $right Step 1 ; Get the color of the current pixel $pixelColor = PixelGetColor($x, $y) $rDiff = Abs(255 - _ColorGetRed($pixelColor)) $gDiff = Abs(255 - _ColorGetGreen($pixelColor)) $bDiff = Abs(255 - _ColorGetBlue($pixelColor)) $distance = Sqrt($rDiff ^ 2 + $gDiff ^ 2 + $bDiff ^ 2) ; Check if the current pixel is closer to white than the previous closest pixel If $distance < $nearestPixelDistance Then $nearestPixelColor = $pixelColor $nearestPixelDistance = $distance $nearestPixelX = $x $nearestPixelY = $y EndIf Next But as I feared autoit cannot keep up with the progress bar. If the area is at the beginning of the bar, autoit isn't finished with finding the area, before the bar reaches it.
Braste84 Posted April 14, 2023 Author Posted April 14, 2023 It is my RedM server which is showing me this bar.
Moderators Melba23 Posted April 14, 2023 Moderators Posted April 14, 2023 Braste84, I feared as much. Please read the forum rules before posting again - thread locked. M23 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: Reveal hidden contents 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
Recommended Posts