Sign in to follow this  
Followers 0
j0sh

How To Check For Pixelcolor When Moused Over...

5 posts in this topic

Here's the situation, I want to mouseover something, and if the pixel = certain color, then left click... I'm kind of confused with this one, cause it won't be using exact coordinates.

If PixelGetColor = 0x7c7470 Then
Endif

Something to do with that I think, hah... thanks for all the replies I get.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try this... not really tested :think::

Opt('PixelCoordMode', 2)
Opt('MouseCoordMode', 2)

Global $Mpos = '', $Color = 0x0000FF;(Blue)

While 1
    $Mpos = MouseGetPos()
    If IsArray($Mpos) Then
        $PixColor = PixelGetColor($Mpos[0], $Mpos[1])
        If ($PixColor == $Color) Then
            MsgBox(0, 'Color Found', 'X: ' & $Mpos[0] & ' Y: ' & $Mpos[1])
        EndIf
        ToolTip('Xcoord = ' & $Mpos[0] & @CR & 'Ycoord = ' & $Mpos[1] & @CR & 'Color = ' & '0x' & Hex($PixColor, 6))
    EndIf
    Sleep(10)
WEnd
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

#3 ·  Posted (edited)

just to help u if your color is what u posted above then it would be

HotKeySet("{esc}","close")
Opt('PixelCoordMode', 2)
Opt('MouseCoordMode', 2)

Global $Mpos = '', $Color = 0x7c7470;(Blue)

While 1
    $Mpos = MouseGetPos()
    If IsArray($Mpos) Then
        $PixColor = PixelGetColor($Mpos[0], $Mpos[1])
        If ($PixColor == $Color) Then
            MsgBox(0, 'Color Found', 'X: ' & $Mpos[0] & ' Y: ' & $Mpos[1])
        EndIf
        ToolTip('Xcoord = ' & $Mpos[0] & @CR & 'Ycoord = ' & $Mpos[1] & @CR & 'Color = ' & '0x' & Hex($PixColor, 6))
    EndIf
    Sleep(10)
WEnd
func close()
    Exit
EndFunc
Edited by thatsgreat2345

Share this post


Link to post
Share on other sites

just to help u if your color is what u posted above then it would be

HotKeySet("{esc}","close")
Opt('PixelCoordMode', 2)
Opt('MouseCoordMode', 2)

Global $Mpos = '', $Color = 0x7c7470;(Blue)

While 1
    $Mpos = MouseGetPos()
    If IsArray($Mpos) Then
        $PixColor = PixelGetColor($Mpos[0], $Mpos[1])
        If ($PixColor == $Color) Then
            MsgBox(0, 'Color Found', 'X: ' & $Mpos[0] & ' Y: ' & $Mpos[1])
        EndIf
        ToolTip('Xcoord = ' & $Mpos[0] & @CR & 'Ycoord = ' & $Mpos[1] & @CR & 'Color = ' & '0x' & Hex($PixColor, 6))
    EndIf
    Sleep(10)
WEnd
func close()
    Exit
EndFunc
:think:

[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

I'm going to take a wild guess here. He's working with Diablo II.

The reason I say this is because Diablo II has its own cursor that replaces a normal cursor and is a general gray color. That way, when you use Au3Info.exe and get the pixel color of the mouse, you're getting gray. 0x7c7470 is not blue, it's gray.

Solution - use 10 pixels up and 10 pixels left of the current position.

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