Sign in to follow this  
Followers 0
PcExpert

Detect colors

14 posts in this topic

Hello,

Does anyone know how to let the program detect a color and then run a command. For example: You have got a white box and after a couple seconds it's red. When it is red it runs your specified command.

Kind Regards,

PcExpert

Share this post


Link to post
Share on other sites



PixelGetColor or PixelSearch.

Share this post


Link to post
Share on other sites

Thanks, but how van I let the program run a command when a specified color is found?

Share this post


Link to post
Share on other sites

Thanks, but how van I let the program run a command when a specified color is found?

If PixelGetColor=desired colour then

do something



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

If (PixelGetColor($x, $y) == $Color) Then
    MyFunction()
EndIf
Comparing 2 numbers you'll need 2 '=' signs here.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

If (PixelGetColor($x, $y) == $Color) Then
    MyFunction()
EndIf
Comparing 2 numbers you'll need 2 '=' signs here.

Can you please make an example of how the code woul'd look like if its is finished?

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

$x = 100
$y = 120
$Color = 0xFFFFFF
If (PixelGetColor($x, $y) == $Color) Then
    MyFunction()
EndIf

Func MyFunction()
    MsgBox(0, 'Found', 'The color was found at those coords')
EndFunc
Kind of a silly question, considering we have no idea what in the world your doing.

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I see that you many times ask how to do things, and where people then respond with how you

can do it yourself. Some times they even go longer and almost create the entire script for you,

but even then you don't seem to try to finish it yourself. I'm sorry, but the code that Smoke gave

you is pretty much every thing you need to know.

If you don't understand it, you should do take a look at your signature..and actually work with AutoIt.

Edit : me english not speak very well, no

Can you please make an example of how the code woul'd look like if its is finished?

Edited by Helge

Share this post


Link to post
Share on other sites

How do I let the detection of the color continue until the color exists. Can I do that with Continue Loop?

Share this post


Link to post
Share on other sites

How do I let the detection of the color continue until the color exists. Can I do that with Continue Loop?

Lookup Do ..... Until


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Thanks,

PcExpert

Can somebody please help me? I have tried to get it to work, but I het ERRORS, I have tried somethings but the ERRORS still show up. Can somebody place the do and until code in this script:

$x = 833

$y = 652

$Color = 0x291808

If (PixelGetColor($x, $y) == $Color) Then

MyFunction()

EndIf

Func MyFunction()

MsgBox(0, 'Found', 'The color was found at those coords')

EndFunc

Kind Regards,

PcExpert

Edited by PcExpert

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

no offence but his name doesnt really fit him :o

Edited by thatsgreat2345

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

I've got it to work now

Edited by PcExpert

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0