Sign in to follow this  
Followers 0
lasse46

Pixelsearch mouseover click?

15 posts in this topic

is it possible to script :

when i hold the mouse over a 0x9ECBFF it makes a mouseclick?

thanks for any help :P

Share this post


Link to post
Share on other sites



is it possible to script :

when i hold the mouse over a 0x9ECBFF it makes a mouseclick?

thanks for any help :P

You want a loop that continuously reads the mouse position with MouseGetPos(), reads the pixel color at that position with PixelGetColor(), and clicks on a match with MouseClick().

Give a shot and post your code if you need more help! :nuke:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

while 1

$pos=mousegetpos()

if pixelgetcolor($pos[0],$pos[1])=10406911 then mouseclick("left",$pos[0],$pos[1],1,0)

sleep(10)

wend

Share this post


Link to post
Share on other sites

Tha Azu but were do i put in the color?

Share this post


Link to post
Share on other sites

10406911 is the decimal value for 0x9ECBFF.

Use windows calc in scientific mode.

Share this post


Link to post
Share on other sites

10406911 is the decimal value for 0x9ECBFF.

Use windows calc in scientific mode.

or, you could say

$HexVaue = "0x"&StringTrimLeft(Hex($DecimalValue),2)

Share this post


Link to post
Share on other sites

or, you could say

$HexVaue = "0x"&StringTrimLeft(Hex($DecimalValue),2)
oÝ÷ Ûú®¢×®;¬¶z-©z÷«ÊØb(v'ßË¥µ«-¯(§ÚyÈ©êÝyȦj[ììZºÚ"µÍÓÜ
    ÌÎNÔ^[ÛÛÜ[ÙIÌÎNËHÈÜ[Û[ÜÛY[ÛÛÜÂÓÜ
    ÌÎNÓ[ÝÙPÛÛÜ[ÙIÌÎNËHÈÜ[Û[ÜÛY[ÛÛÜÂÚ[HBIÌÍÜÜÈH[ÝÙQÙ]ÜÊ
BRY
^[Ù]ÛÛÜ ÌÍÜÜÖÌK   ÌÍÜÜÖÌWJHOHQPÐH[[ÝÙPÛXÚÊ    ][ÝÛY ][ÝË  ÌÍÜÜÖÌK   ÌÍÜÜÖÌWKK
BTÛY
L
BÑ[
Brackets around it and a double = for exact match will help here.

[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

#8 ·  Posted (edited)

Or just not make everything so difficult as trying to decipher decimal vs hex

;Opt('PixelCoordMode', 2) ; Optional for client coords
;Opt('MouseCoordMode', 2) ; Optional for client coords
While 1
    $pos = MouseGetPos()
    If (PixelGetColor($pos[0],$pos[1]) == 0x9ECBFF) Then MouseClick("left", $pos[0], $pos[1], 1, 0)
    Sleep(10)
WEnd
Brackets around it and a double = for exact match will help here.

How can that work

PixelGetColor returns decimal values, so comparing to hex can't work

PixelGetColor

Returns a pixel color according to x,y pixel coordinates.

PixelGetColor ( x , y )

Parameters

x x coordinate of pixel.

y y coordinate of pixel.

Return Value

Success: Returns decimal value of pixel's color.

Edited by Paulie

Share this post


Link to post
Share on other sites

How can that work

PixelGetColor returns decimal values, so comparing to hex can't work

You should really search things or test them before you post such a thing... That's like saying that
MsgBox(64, 'Info', 0xFF0000)
Should show the hex value, and not the decimal... but if you run it, what do you get?

[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

You should really search things or test them before you post such a thing... That's like saying that

MsgBox(64, 'Info', 0xFF0000)
Should show the hex value, and not the decimal... but if you run it, what do you get?
lol, well thats news to me

thats one shortcut i didn't know about :">

sorry :"> :">

Share this post


Link to post
Share on other sites

Thanks alot! but if i want 5 colors similar to 10406911.. how do i write then?

if pixelgetcolor($pos[0],$pos[1])=10406911, 5 then ???

Share this post


Link to post
Share on other sites

Thanks alot! but if i want 5 colors similar to 10406911.. how do i write then?

if pixelgetcolor($pos[0],$pos[1])=10406911, 5 then ???

You would either put those 5 colors in an array and do a For/Next 1 to 5, or do 5 "If" statements if you are looking for exactly those colors.

[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

Thanks alot! but if i want 5 colors similar to 10406911.. how do i write then?

if pixelgetcolor($pos[0],$pos[1])=10406911, 5 then ???

You would use PixelSearch() instead of PixelGetColor() if wanted shade variations (near matches). Check it out in the help file!

:P


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Hi, won't the code I posted work? :S

Share this post


Link to post
Share on other sites

Hi, won't the code I posted work? :S

It's not that it won't work Azu, just more work than neccessary, take a look at the example I posted as to why.

[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