Sign in to follow this  
Followers 0
anyday

Color under mouse

4 posts in this topic

hey guys, been awhile since i last posted here. was gonna see if it was possible to hold exec of the script until the color under the mouse was at a certain hex ? like if i set the mouse pos on the screen and the script had to wait until the RGB hex of that area was a set hex before script continued?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

hey guys, been awhile since i last posted here. was gonna see if it was possible to hold exec of the script until the color under the mouse was at a certain hex ? like if i set the mouse pos on the screen and the script had to wait until the RGB hex of that area was a set hex before script continued?

Get the mouse position then check the color

While 1
$pos = MouseGetPos
$Color = PixelGetColor($pos[0], $pos[1])
If $color = *Your Color* then
;Do Whatever
Endif
Wend

EDIT:

Of course this is for the decimal of a color, not hex, not sure how to get hex out of a PixelGetColor

Edited by Paulie

Share this post


Link to post
Share on other sites

Hmmm someone wrote this block to play a game where a ball bounces around the screen and the mouse moves with it. might help

While 1
    $a = MouseGetPos()
    If Not @error Then
        $b = PixelSearch($a[0] - 80,$a[1] - 50,$a[0] + 80,$a[1] + 50,0xA7FF92)
        If Not @error Then
            MouseMove($b[0],$b[1],0)
        Else
            $b = PixelSearch($a[0] - 80,$a[1] - 50,$a[0] + 80,$a[1] + 50,0xEBFFE7)
            If Not @error Then  MouseMove($b[0],$b[1],0)
        EndIf
    EndIf
    Sleep(0)
WEnd

Share this post


Link to post
Share on other sites

Opt('MouseCoordMode', 2)
Opt('PixelCoordMode', 2)
While 1
    Sleep(10)
    $aMpos = MouseGetPos()
    $HexPix = '0x' & Hex(PixelGetColor($aMpos[0], $aMpos[1]), 6)
    ToolTip('Hex Color = ' & $HexPix & @CR & _
            'Client X:Y = ' & $aMpos[0] & ',' & _
                $aMpos[1], $aMpos[0] + 20, $aMpos[1] + 20)
WEnd


[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

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