Jump to content

Checking for colour


Recommended Posts

I am trying to run a simple little script that will check for a particular colour pixel in a small box and then return its coordinates.

This is it:

    Local $aCoord = PixelSearch(830,440,1030,640,0x69ADF2)
    if not @error Then
msgbox(0,"Func", "X Y" & $aCoord[0] & "," & $aCoord[1] )

    Sleep (500)
    EndIf
    

It will be called as a function and the "msgbox" bit will be replaced but this is just for testing.

 

It will run but doesnt give me the msgbox so is it detecting the colour? I thought the "not @error" should make it wait until it see the condition?

 

thanks

Link to comment
Share on other sites

  • Moderators

@andyjw1 what exactly are you trying to automate (web page, desktop app, etc.). As you are beginning to see, PixelSearch is about the worst way you can go about checking for the presence of, or change in, a window. I can guarantee there is an easier way, if you can give us a bit more info.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Im am just starting to learn so all I am trying to do is detect a particular moving colour within a 200 pixel box.

I eventually want to follow a point in a video image which will then output to a DMX program which will in turn control a moving light to follow the same spot. Hope that made sense :)

 

Link to comment
Share on other sites

  • Moderators

Nope, still a little too vague for me. Good luck in your endeavors, perhaps someone will wander by and offer assistance. :)

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Sorry, Ill try and be a bit clearer.

I have a light on a stage that I can move using an app on the PC so that I can follow a person around the stage, like a spotlight on a comedian.

What I want to do is point a video camera at the stage and use the code to detect where the person is within the video image, it will then control the light.

 

Any better?

Thanks

Link to comment
Share on other sites

While 1
    Local $aCoord = PixelSearch(830,440,1030,640,0x69ADF2)
    If $aCoord Then
      MsgBox(0,"Func", "X Y" & $aCoord[0] & "," & $aCoord[1] )
      Sleep (500)
      ExitLoop
    EndIF
WEnd

This will loop and keep going until the pixel is found. If it still isn't being found, make sure your bounds are correct, and also make sure the shade is EXACTLY correct since you have the shade-variation set to 0.

UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI=

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...