Jump to content

Color Ranges?


Recommended Posts

I am currently just messing around in AutoIt, and I have a question about a script I am making.

The script is supposed to leftclick at 0,0 when the pixel at 0,0 is either blue or red.

My question is wether or not I can have it click for every shade of red or blue.

Heres some of what I have so far:

$pixel = pixelgetcolor(0,0)
$hexpx = hex($pixel, 6)

If $hexpx = (0xff0000) then
    mousedown("left")
    sleep 10
    mouseup("left")
    soundplay("C:\WINDOWS\Media\Windows XP Default.wav")
endif

If $hexpx = (0x0000ff) then
    mousedown("left")
    sleep 10
    mouseup("left")
    soundplay("C:\WINDOWS\Media\Windows XP Default.wav")
endif

I havent even tested it yet (:() but what I need is for the

If $hexpx = (0x0000ff) then

To be a range, from say (0x000022) to (0x0000ff), instead of the fixed "Completely Blue" thing thats goin on now.

Can someone explain to me how to do this?

Edited by Khetti
Link to comment
Share on other sites

Maybe you should look at PixelSearch() with shade variation parametres. But because you only want to search/get the colour at one point maybe you shouldn't :(. You could get the convert the blue from the colour found to the blue conponent colour. And if the colour is greater then "22"(Hex) converted to the blue component, range 0-255, and less then "FF"(Hex).And put that in an if statement

Currently in PixelSearch() you can only search a Red, Green and Blue for the colour change all at once. Let me explain

Say I want use search for 0x000000, with a shade variation of 55, it will return any colour in the range of 0x000000 - 0x373737. You can't choose a different variation for each RGB component.

If you don't understand me fully np. I made it a bit confusing :"> .

qq

Link to comment
Share on other sites

Having the same shade variation is fine, just as long as I can search both red and blue.

I'll look into it, thanks!

EDIT:

Ok, heres what I have so far:

$pixelr = pixelsearch(-400, 300, 400, -300, 0x110000, 255, 24)
$pixelb = pixelsearch(-400, 300, 400, -300, 0x000011, 255, 24)

If $pixelr = (0,0) then
        mousedown("left")
    sleep 10
    mouseup("left")
    soundplay("C:\WINDOWS\Media\Windows XP Default.wav")
endif

If $pixelb = (0,0) then
    mousedown("left")
    sleep 10
    mouseup("left")
    soundplay("C:\WINDOWS\Media\Windows XP Default.wav")
endif

But it doesnt seem to work...

What I am trying to get is to have it mousedown for a brief moment when a blue or red pixel is under the mouse (which is always at 0,0)

I am probably overlooking something simple, but if you could take a look at it I would appreciate it.

Edited by Khetti
Link to comment
Share on other sites

  • Moderators

If $pixelb = (0,0) then

    mousedown("left")

    sleep 10

    mouseup("left")

    soundplay("C:\WINDOWS\Media\Windows XP Default.wav")

endif

Should your "sleep 10" be
Sleep(10)
?

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

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