PixelSearch won't find the color I'm looking for Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
yasqueenslay
Posts: 22
Joined: 17 Oct 2019, 05:59

PixelSearch won't find the color I'm looking for

Post by yasqueenslay » 21 Mar 2023, 14:02

Hi,

The problem: I want to have a script move the mouse cursor over the 'add to chrome' button of a chrome extension page (using this one: https://chrome.google.com/webstore/detail/google-translate/aapbdbdomjkkjkaonfhkkikfgjllcleb)
My approach: Use PixelSearch to find the color of a given pixel in the button.

Code: Select all

f::
CoordMode,  Pixel, Screen
PixelSearch, Px, Py, 0, 0, 1920, 1000, 0x1A73E8, 0, Fast
if ErrorLevel
    MsgBox, That color was not found in the specified region.
else
	MsgBox, results, %Px%, %Py%
Somehow, the color is never found.

Any ideas where I'm going wrong? My screen res is 1920x1080 (but I do have multiple monitors, don't know if that could interfere with this)

Thanks!

Also tried this to no avail (with the jpg being a snippet of the button in image form)

Code: Select all

f::
	CoordMode Pixel  ; Interprets the coordinates below as relative to the screen rather than the active window.
	ImageSearch, FoundX, FoundY, 0,0,1900,1070, C:\Users\<myWinUser>\addto.jpg
	if (ErrorLevel = 2)
	    MsgBox Could not conduct the search.
	else if (ErrorLevel = 1)
	    MsgBox Icon could not be found on the screen.
	else
	    MsgBox The icon was found at %FoundX%x%FoundY%.

RussF
Posts: 1261
Joined: 05 Aug 2021, 06:36

Re: PixelSearch won't find the color I'm looking for  Topic is solved

Post by RussF » 21 Mar 2023, 14:09

PixelSearch defaults to colors in BGR format. The color you have listed is in RGB format. Try instead:

Code: Select all

PixelSearch, Px, Py, 0, 0, 1920, 1000, 0x1A73E8, 0, Fast RGB
Russ

yasqueenslay
Posts: 22
Joined: 17 Oct 2019, 05:59

Re: PixelSearch won't find the color I'm looking for

Post by yasqueenslay » 21 Mar 2023, 14:22

RussF wrote:
21 Mar 2023, 14:09
PixelSearch defaults to colors in BGR format. The color you have listed is in RGB format. Try instead:

Code: Select all

PixelSearch, Px, Py, 0, 0, 1920, 1000, 0x1A73E8, 0, Fast RGB
Russ
Yep, that fixed it! Thanks.

Could there be a similar issue when looking for an image on the screen? (my 2nd code example in OP). For reference, I'm using this image Image

RussF
Posts: 1261
Joined: 05 Aug 2021, 06:36

Re: PixelSearch won't find the color I'm looking for

Post by RussF » 21 Mar 2023, 14:41

yasqueenslay wrote: Could there be a similar issue when looking for an image on the screen? (my 2nd code example in OP). For reference, I'm using this image
There shouldn't be because you are looking for an image, not a color. Your reference image should be in .PNG format, not .JPG which is compressed.

Russ

yasqueenslay
Posts: 22
Joined: 17 Oct 2019, 05:59

Re: PixelSearch won't find the color I'm looking for

Post by yasqueenslay » 22 Mar 2023, 13:17

That's amazing, now both work. Much obliged, thanks!

Post Reply

Return to “Ask for Help (v1)”