PixelGetColor -> Invert result? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
NoGuest

PixelGetColor -> Invert result?

18 May 2018, 16:23

Hi,
When I use PixelGetColor, is it possible that AHK gives me the negative/inverted color?
E.g. the pixel is white and the result should be black.

The code could be something like:

Code: Select all

F1:: 
MouseGetPos, MouseX, MouseY
PixelGetColor, color, %MouseX%, %MouseY%
invColor := FFFFFF - color
Clipboard := invColor
return
Unfortunately I'm sitting on a MAC right now and can't do any tests...
I have no idea if this code might work...

Maybe I have to split the color variable into 3 parts (because it consists of red, green and blue).
After this I might calculate:
FF - part 1
FF - part 2
FF - part 3
invColor = %part1%%part2%%part3%
The result would be 000000 (black).

And I don't have my AHK login here either :|
Any help would be great!
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: PixelGetColor -> Invert result?

18 May 2018, 18:14

2 ways:

Code: Select all

magenta := 0xFF00FF
MsgBox, % cyan := "0x" SubStr(Format("{:x}", ~magenta), 3)
if (cyan = 0x00FF00)
	MsgBox, % "yep, thats cyan alright"

Code: Select all

magenta := 0xFF00FF
MsgBox, % cyan := magenta ^ 0xFFFFFF
; MsgBox, % cyan := Format("{:x}", cyan) ; this is optional
if (cyan = 0x00FF00)
	MsgBox, % "also cyan"
NoGuest

Re: PixelGetColor -> Invert result?  Topic is solved

20 May 2018, 15:54

Thanks for your answer.
I will try it out when I'm at home again.

Just a question:
Why was my first post marked as "solved"?
Does it mean my code is already correct?
I didn't mark it as solved...
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: PixelGetColor -> Invert result?

20 May 2018, 16:14

i think the forum does it automatically for unregistered users after some time has passed

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Holarctic, mapcarter, robnicholson and 344 guests