Jump to content

Color under mouse


Recommended Posts

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?

Link to comment
Share on other sites

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
Link to comment
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
Link to comment
Share on other sites

  • Moderators

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

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