Jump to content
Sign in to follow this  
tech2

pixelsearch help

Recommended Posts

tech2

hi first off im a newbie and need a lil help with with a macro im making. PixelSearch( 907, 630, 907, 630, 0xFFFFFF ) ok when that is true i want to preform an action like mouse click then when it can not find 0xFFFFFF anymore it preforms another mouseclick. hope not too confusing :)

Share this post


Link to post
Share on other sites
SpookMeister

Instead of PixelSearch, you probably want to use PixelGetColor because PixelSearch does not return true/false per se, instead it returns an array of the coordinates where it finds the color you want (or returns an error).


[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites
tech2

Instead of PixelSearch, you probably want to use PixelGetColor because PixelSearch does not return true/false per se, instead it returns an array of the coordinates where it finds the color you want (or returns an error).

can u give me an example with pixelgetcolor with wat i was asking?

Share this post


Link to post
Share on other sites
jebus495

$color = PixelGetColor(907,630)

If $color = 0xFFFFFF Then

MsgBox(0,"color is white")

Else

MsgBox(0,"color is not white)

EndIf

?

If you could give a more detailed explanation of what you are trying to do that might help. :)

Share this post


Link to post
Share on other sites
tech2

$color = PixelGetColor(907,630)

If $color = 0xFFFFFF Then

MsgBox(0,"color is white")

Else

MsgBox(0,"color is not white)

EndIf

?

If you could give a more detailed explanation of what you are trying to do that might help. :)

for instance if the coridents (907,630) are 0xFFFFFF it does nothing but when 0xFFFFFF changes to 0xertfde MsgBox(0,"color changed")

are even only MsgBox(0,"color changed") when (907,630) = 0xertfde

Share this post


Link to post
Share on other sites
SpookMeister

HotKeySet("{ESC}", "Terminate")
$x = 907
$y = 630
$LastColor = PixelGetColor($x, $y)
While 1
    Sleep(100) ; always a good idea to avoid max'ing your CPU
    $check = PixelGetColor($x, $y)
    ToolTip($check) ; Just for testing
    Select
        Case $check <> $LastColor
            Select
                Case $check = 0xFFFFFF ; You may need to tweak this value
                    MouseClick("left", 123, 456) ; adjust to where you want to click
                Case $check = 0x000000 ; some other value, again tooltip should tell you
                    MouseClick("left", 300, 300) ; again adjust to where you want to click
            EndSelect
    EndSelect
WEnd

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

[edit] tweaked code a bit to make it simpler [/edit]

Edited by SpookMeister

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.