How to use the command referring to the pixel color of the mouse position? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
gabrielquaglio
Posts: 6
Joined: 22 Nov 2021, 21:50

How to use the command referring to the pixel color of the mouse position?

Post by gabrielquaglio » 26 Sep 2022, 23:10

I already know the color code and the mouse position, I don't want to know how to get them, I want to know how to use the command already having the HEX or RGB color code, I want the following.

"if mouse position "x" is equal to one pixel of white color, show message x, if not, show message "y"

that simple


I'm trying to no avail.

Code: Select all

f2::
MouseMove 949, 161

If (MouseGetPos, 949, 161 = 0xFFFFFF)
   {
      msgbox, you win
         }
else
    {
       msgbox, you lose
          }
return
[Mod edit: [code][/code] tags added.]
Last edited by gregster on 26 Sep 2022, 23:14, edited 1 time in total.
Reason: Topic moved from 'Scripts and Functions'.

Rohwedder
Posts: 7551
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How to use the command referring to the pixel color of the mouse position?  Topic is solved

Post by Rohwedder » 27 Sep 2022, 03:07

Hallo,
it must be very frustrating to test self made up commands! Try:

Code: Select all

f2::
MouseMove 949, 161
If MouseGetColor() = 0xFFFFFF
	msgbox, you win
else
	msgbox, you lose
return

MouseGetColor()
{
	CoordMode, Mouse,% A_CoordModePixel
	MouseGetPos, MouseX, MouseY
	PixelGetColor, color, MouseX, MouseY
	Return, color
}

Post Reply

Return to “Ask for Help (v1)”