We help IT Professionals succeed at work.

AutoIT - How to wait on a button color change

Accidental Hyper-V Administrator
Accidental Hyper-V Administrator asked
Good morning everyone,

AutoIT newb here.

I am using AutoIT V3.

I am testing an application via an AutoIT script.

What I am doing:
I navigate to a location and left click on a button.
At that point, the button turn from green to grey.
I wait "sleep (20000)" for 20 seconds.
Then I continue with my script.

What I want to do:
Instead of waiting for 20 seconds, I want the Auto IT script to do nothing, until the button turns green again.
Atwhich point, I want the script to continue on its merry way.

I can’t for the life of me,figure out how to "do" such a thing.

Any help would be greatly appreciated.

Thanks in advance.

Ray in Wisconsin
Watch Question

Use something like PixelGetColor (see AutoIT Help for more information)

Usually something like: (Note haven't tested)

$Color_Gray = 'C0C0C0'
$Color_Green = '00FF00'

MouseClick('left', x, y)
While 1
  If Hex(PixelGetColor(x, y), 6) = $Color_Green Then ExitLoop

Open in new window

After the Wend you'd continue with your code.

You’re the greatest !

Ray in Wisconsin