Page 1 of 1

PixelGetColor does not work !

Posted: 18 Feb 2020, 04:43
by techniker_rentner
Hi, I'm a newcomer, so please be patient!
Since years I work with AHK and found always, somehow, a solution. But now I simply try to find out the color under my cursor but it does not work!

Code: Select all

CoordMode, Mouse Pixel, Screen
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
MouseGetPos, MouseX, MouseY
PixelGetColor, color, MouseX, MouseY, RGB
MsgBox The color at the current cursor position is %color%.
return
[Mod edit: Codebox fixed.]

I tried it in many ways, but it simly does not work! It shows always the same "0xffffff". I tried to use other commands, using the "windows spy" mouse position and control to reach my target, but they also did not work in the one or the other way:
ControlGetPos
WinGetTitle
WinGetClass

Where is my mistake?
I#m using WIN7, AHK 1.1.30.2

Re: PixelGetColor does not work !

Posted: 18 Feb 2020, 08:49
by Yakshongas
Try this.

Code: Select all

SetWorkingDir %A_ScriptDir%

Loop
{
MouseGetPos, PosX, PosY
PixelGetColor, colors, %PosX%, %PosY%
ToolTip, X: %PosX% Y: %PosY% `nColor: %colors%
}
F5::
Clipboard = %PosX%, %PosY%, %colors%
return

Re: PixelGetColor does not work !

Posted: 18 Feb 2020, 09:14
by scriptor2016

Code: Select all

#Persistent
CoordMode Pixel, Screen 
CoordMode Mouse, Screen 
SetTimer, WatchCursor, 100
return

WatchCursor:
MouseGetPos X, Y 
PixelGetColor Color, %X%, %Y%, RGB
ToolTip, %Color%

Re: PixelGetColor does not work !

Posted: 18 Feb 2020, 09:53
by techniker_rentner
It still shows color 0xFFFFFFFF !

Re: PixelGetColor does not work !

Posted: 18 Feb 2020, 10:01
by techniker_rentner
Thank you scriptor2016 and Yakshongas! It seems that the "PixelGetColor" itself does not work!? Any other possibilities?

Re: PixelGetColor does not work !

Posted: 19 Feb 2020, 06:31
by Hellbent
techniker_rentner wrote:
18 Feb 2020, 10:01
Thank you scriptor2016 and Yakshongas! It seems that the "PixelGetColor" itself does not work!? Any other possibilities?
See if this script works for you.

https://www.autohotkey.com/boards/viewtopic.php?f=6&t=60942

Re: PixelGetColor does not work !

Posted: 19 Feb 2020, 09:23
by techniker_rentner
Thank you Hellbent,
I just extracted the section "GETCOLORFROMSCREEN" from your script, modified it and - surprise - it worked!! I compared it with my script, but I did'nt find any error! I modified it in a lot of ways, but it never worked. Anyway, it works now and I thank you very much!

Re: PixelGetColor does not work !

Posted: 19 Feb 2020, 11:30
by techniker_rentner
To all who helped and to all who may have similar problems!
I found the problem why my script did not work properly! My firewall blocked it (COMODO)! Somehow the message service was deactivated, so that COMODO did not report it to me! Nevertheless I could start the script, but it showed wrong results. Sometimes, but not everytime, during the starting process, AUTOHOTKEY sent a warning: The keyboard and/or mouse hook could not be activated. Ignoring this warning brought the same wrong results!
After deleting the script from COMMODO's blocking list and mark it as trustworthy, it worked perfectly!