Sign in to follow this  
Followers 0
Jasio

Find/Move Mouse To Color

13 posts in this topic

I was wondering if there was a simple script that would find a color preset in the script, i would also like to know if there is a script to fine the exact color "hex" to make detection simpler

Thanks,

Jasio-

Share this post


Link to post
Share on other sites



Pixelgetcolor/PixelSearch in the helpfile.


[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)

um pixelsearch(0,0,500,500,URHEXCOLOR) us the au3info that comes with autoit

:lmao: i thought i was gonna beat u on this one i guess not

Edited by thatsgreat2345

Share this post


Link to post
Share on other sites

Ya, i tried that before coming here.. it gives me "0" for decimal, "00000" for hex.., (used from the example file), any specific way to use this command..

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

$Blah = PixelGetColor(0, 100)

MsgBox(0, 'Test', '0x' & Hex($Blah, 6))

Edit: Be sure your using the Correct PixelCoordMode depending on the type of coordinates your collecting. Check out Opt('PixelCoordMode', #) in the help.

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

Ya.. basically the same code from the Example file.. gives me 0x00000 this time though =/

Share this post


Link to post
Share on other sites

take a screenshot and put it in paint that should give u the right thing but only BMPs contain the actual hex so dont save it as a .jpg if u do save it

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Look at my edit:

Edit:

I typically use client coords, so I'll show you an example (to use client coords in the autoinfo tool, go to options / coord mode)

Opt('PixelCoordMode', 2)
$Blah = PixelGetColor(100, 100)
MsgBox(0, 'Test', '0x' & Hex($Blah, 6))

P.S., the color at that time at those coordinates could have been black is why you were getting 0x000000

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

#9 ·  Posted (edited)

Ok, worked, now for my second question, say i want the script to find this hex color, than click on its location (read full screen) and click this color..

Edited by Jasio

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Hmmm, as usual I mis-understood your post... To get the color under the mouse there are 5 things you'll want to look at in detail:

1. PixelCoordMode

2. MouseCoordMode

3. _IsPressed() A UDF that is in the Misc.au3 file of the Beta Version of Autoit (See my signature)

4. MouseGetPos

5. PixelGetColor

So an example would be: (I'll include the UDF to help you a bit)

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

While 1
    If _IsPressed('01') Then; '01' identifies the left mouse button
        Local $Pos = MouseGetPos()
        $PixColor = PixelGetColor($Pos[0], $Pos[1])
        ToolTip('The Colour is: 0x' & Hex($PixColor, 6))
    EndIf
    Sleep(10)
WEnd

Func _IsPressed($s_hexKey, $v_dll = 'user32.dll')
    Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey)
    If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1
    Return 0
EndFunc

Edit: For Search You'll use PixelSearch()

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

Local $xTopLeft = 0; starting point
Local $yTopLeft = 0; starting point
Local $xBottomRight = 200 
Local $yBottomRight = 200
Local $ColorToFind = 0xFF0000

While 1
    Local $PixSearch = PixelSearch($xTopLeft, $yTopLeft, $xBottomRight, $yBottomRight, $ColorToFind)
    If Not @error And IsArray($PixSearch) Then MouseClick('Left', $PixSearch[0], $PixSearch[1], 1, 1)
    Sleep(100)
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

I'm sorry for the miscommunication, i can't seem to word them better.. This script is for a game, i would like it to find a specific color (which is basically a red/orange circle in a large grey area.. then click on it

a problem im having is, when i get the hex color, E0DFE3, i put it in the PixelSearch, it then gives me coords 0, 48.. The object in which i want it to locate is in the middle of the screen and no where near the top left.

I hope this clears up more of this than it complicates

Thanks,

Jasio

Share this post


Link to post
Share on other sites

I edited the above post to show you how already :lmao:


[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

Hrmm.. It made everything really laggy.. i cancelled after about 3 minutes.. it just stood there, how long could this take to find the color.. and how do i know if it is even working

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