Jump to content

Recommended Posts

Posted

Hello

I'm a new autoit user, I'm not a programmer - I'm just playing out of curiosity. But I have a question/problem:

With the help of the Internet, I wrote a simple code that aims to press the "DEL" key when a given color appears on the screen, and then I want the code to wait until the effect of pressing "DEL" disappears, i.e. until the next color disappears. The problem is that the second color does not always disappear after the same time. I tried to write the code to check whether the color is still on the screen, if it is, it will wait longer and if not, it will start the loop from the beginning, but the code continues even if the color is on the screen:

 

While 1
    $color = PixelGetColor(3502, 57)
    
    If $color <> 0x4D4D4D Then
        Send("{DEL}")
        
        While PixelGetColor(3494, 65) = 0xFF0000
            Sleep(100)
        WEnd

        MouseMove(100, 100)
    EndIf


The point is that I want the code to check whether the color 0xFF0000 is on the screen, if it is, it will wait 1 second and check again and so on until it is gone and then move on. I don't know what the problem is? Should GetPixelColor be at the very beginning of the code for this to work? or whatever it is

Thanks up for answer

Posted

Print to console the read colors and make sure it's the expected color at the expected coordinates:

While True
    $FirstColor = PixelGetColor(3502, 57)
    If $FirstColor <> 0x4D4D4D Then
        ConsoleWrite('First color: 0x' & Hex($FirstColor, 6) & @CRLF)
        Send("{DEL}")
        
        Do 
            $SecondColor = PixelGetColor(3494, 65)
            ConsoleWrite('Second color: 0x' & Hex($SecondColor, 6) & @CRLF)
            Sleep(100)
        Until $SecondColor <> 0xFF0000

        MouseMove(100, 100)
    EndIf
WEnd

 

Posted

Unfortunately, it's still the same, the code checks the first color and finds differences, but when looking for the second color, it still moves on after the first search instead of waiting for the color to disappear.

 

First color: 0x0A0502
Second color: 0x4A4A4A
First color: 0x0A0502
Second color: 0x4A4A4A
First color: 0x323C41
Second color: 0x4A4A4A
First color: 0x323C41
Second color: 0xFF0000
First color: 0x323C41
Second color: 0x000000
First color: 0x323C41
Second color: 0xFF0000
First color: 0x323C41
Second color: 0x000000
First color: 0x323C41
Second color: 0xFF0000
First color: 0x323C41
Second color: 0x4A4A4A
First color: 0x323C41
Second color: 0xFF0000
First color: 0x323C41
Second color: 0xFF0000
First color: 0x0A0502
Second color: 0x4A4A4A
First color: 0x0A0502
Second color: 0x4A4A4A
First color: 0x0A0502
Second color: 0xFF0000
First color: 0x0A0502
Second color: 0xFF0000

As you can see, the code finds the second color but does not check again whether it is still on the screen, it just moves on

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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