Jump to content

Recommended Posts

Posted

Hello.

I have a problem which I don't know, how to solve at the moment.

I have this progress bar

image.png.102f4ee10159a0603a97c15557164c10.png

As soon as it hits the area separated by the two lines, I need to press a button

image.png.b21b14a908ab119b5afd2cbad97b662f.png

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?

Posted (edited)
Posted (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 by Braste84
Posted (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 by Braste84
  • Moderators
Posted

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.

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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

 

Posted

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.

  • Moderators
Posted

Braste84,

I feared as much. Please read the forum rules before posting again - thread locked.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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

 

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...