Jump to content

Detect colors


Recommended Posts

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

Link to comment
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


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

Link to comment
Share on other sites

  • Moderators

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

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.

Link to comment
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?

Link to comment
Share on other sites

  • Moderators

$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

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.

Link to comment
Share on other sites

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
Link to comment
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


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

Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

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