Sign in to follow this  
Followers 0
steelys

How do i get the true color of a pixel if..

10 posts in this topic

I tried using PixelGetColor but the results were 0 and i guess the game disables pixel color grabbing thingy. So is there anyway i can get the true color of the pixel ?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi!

From the help file:

Return Value

Success: Returns decimal value of pixel's color.

Failure: Returns -1 if invalid coordinates.

...

$var = PixelGetColor( 10 , 100 )

MsgBox(0,"The decmial color is", $var)

MsgBox(0,"The hex color is", Hex($var, 6))

The return values 1 and 0 indicate black and white pixels.

Good luck with further scripting, peethebee

Edited by peethebee

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvGerman Forums: http://www.autoit.deGerman Help File: http://autoit.de/hilfe vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

Share this post


Link to post
Share on other sites

Yeah, but the problem is the pixel color is clearly not black/white, its some other. I guess the game could have some protection that makes all pixel grabbing programs to think that its a black/white pixel.

Share this post


Link to post
Share on other sites

Hi!

I can rarely imagine this. Could you please post your code aroun this function call and a jpeg screenshot i possible?

Thank you, peethebee


vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvGerman Forums: http://www.autoit.deGerman Help File: http://autoit.de/hilfe vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

Share this post


Link to post
Share on other sites

My code is

$pos = MouseGetPos()
$color = PixelGetColor ( $pos[0] , $pos[1] )
Msgbox( 1, "Test", $color )

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

You are very likely checking the colour of the tip of your mouse pointer. Does this work for you? --

Edit: It seems that this mouse-moving procedure is only really needed if you're in some form of game where the mouse pointer is custom-drawn. PixelGetColor() doesn't seem to notice the cursor when dealing with ordinary Windows.

local $pos = mouseGetPos()
mouseMove($pos[0] + 1, $pos[1] + 1)
local $color = pixelGetColor($pos[0] , $pos[1])
mouseMove($pos[0], $pos[1])
Msgbox(0x40, "Colour at Cursor", $color)
Edited by LxP

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Hi!

What would this line (instead of your debug line) produce:

MsgBox(0,"The hex color is", Hex($color, 6))

?

Edit: very nice idea of LxP. Please test his solution first.

peethebee

p.s. no screenshot possible?

Edited by peethebee

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvGerman Forums: http://www.autoit.deGerman Help File: http://autoit.de/hilfe vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Thanks alot for all of your reply. I really appreciate it.

I tried LxP code and it work ! Thanks alot dude ! and not forgetting peethebee ;)

Thanks both of you !

EDIT:

i tried it and it gave me the true pixel color, but if i run the program twice with the code below

local $pos = mouseGetPos()
mouseMove(515, 133)
sleep(1000)
local $color = pixelGetColor($pos[0] , $pos[1])
Msgbox(0x40, "Colour at Cursor", $color)

It gave me 2 different color *answer*. Everytime i run it, it would give me a different color. How do i go about solving that ?

Thanks once again

Edited by steelys

Share this post


Link to post
Share on other sites

Hi!

It is depending on the MousePos and if you position it by hand, you cannot (or almost not) be pover the same pixel...

peethebee


vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvGerman Forums: http://www.autoit.deGerman Help File: http://autoit.de/hilfe vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

Share this post


Link to post
Share on other sites

Another thought: games often use antialiasing which results in subtle variations of colours at any one time. 3D games are particularly hard to process (although not impossible) because there are always different shades of the colour in question.

You may want to consider PixelSearch() with a 1x1 search rectangle as a solution as you will be able to specify an acceptable shade variation.

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