ImageSearch or PixelSearch dont work at second monitor

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
roofik5
Posts: 23
Joined: 03 Jan 2021, 10:52

ImageSearch or PixelSearch dont work at second monitor

05 Aug 2023, 12:56

Hi i have script like below, on my netbook it works perfect but when I connect second monitor via USB-C (display only on second monitor, screen on netbook is off) it cant find those images on screen, how can I fix it?

Code: Select all

Process, Priority, , A

SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
IniRead, xHP50, USTAWIENIA.ini, HP50, xHP50   
IniRead, yHP50, USTAWIENIA.ini, HP50, yHP50		
IniRead, HP50color, USTAWIENIA.ini, HP50, HP50color  


IniRead, xRING, USTAWIENIA.ini, RING, xRING		
IniRead, yRING, USTAWIENIA.ini, RING, yRING		

IniRead, xBP, USTAWIENIA.ini, BP, xBP		
IniRead, yBP, USTAWIENIA.ini, BP, yBP		


IniRead, MANArhot, USTAWIENIA.ini, MANArhot, MANArhot


Hotkey, %MANArhot%, MyHotkey
PixelGetColor, Check50, %xHP50%, %yHP50%, RGB


Loop {
ImageSearch, aXXX, bYYY, 0, 0, A_ScreenWidth, A_ScreenHeight, riing.PNG
	
PixelGetColor, Check50, %xHP50%, %yHP50%, RGB

}
MyHotkey:


{


	{
	ImageSearch, aXX, bYY, 0, 0, A_ScreenWidth, A_ScreenHeight, utama.PNG
	if ErrorLevel{
	BlockInput MouseMove
	MouseGetPos, X, Y
	if (A_Cursor != "Arrow") {
Click, Right
}

	MouseClickDrag, L, %aXXX%, %bYYY%, %xRING%, %yRING%
	MouseMove, %X%, %Y%
	BlockInput, MouseMoveOff
	sleep 322

	}
		else 
		{
		if (Check50 = HP50color){
			BlockInput MouseMove
	MouseGetPos, X, Y
		if (A_Cursor != "Arrow") {
Click, Right
}
		MouseClickDrag, L, %xRING%, %yRING%, %xBP%, %yBP%
			MouseMove, %X%, %Y%

		BlockInput, MouseMoveOff
		sleep 1210
		}
		else {
		}

		}
		}
}

return
gregster
Posts: 9111
Joined: 30 Sep 2013, 06:48

Re: ImageSearch or PixelSearch dont work at second monitor

05 Aug 2023, 13:05

Please use the forums marked with (v1) in their names, if you are asking about or posting AHK v1 code. The main release is now AHK v2 - its forums are named accordingliy.
But no worries, I moved this topic for you from AHK v2 to v1 help.
ntepa
Posts: 439
Joined: 19 Oct 2022, 20:52

Re: ImageSearch or PixelSearch dont work at second monitor

05 Aug 2023, 14:00

0, 0, A_ScreenWidth, A_ScreenHeight are the coordinates of the first monitor. If you want to ImageSearch in all monitors, try this:

Code: Select all

; Put this in the auto-execute section.
SysGet, vLeft, 76
SysGet, vTop, 77
SysGet, vWidth, 78
SysGet, vHeight, 79
vRight := vLeft + vWidth
vBottom := vTop + vHeight

; Replace 0, 0, A_ScreenWidth, A_ScreenHeight with vLeft, vTop, vRight, vBottom
ImageSearch, aXXX, bYYY, vLeft, vTop, vRight, vBottom, riing.PNG
roofik5
Posts: 23
Joined: 03 Jan 2021, 10:52

Re: ImageSearch or PixelSearch dont work at second monitor

05 Aug 2023, 14:19

unfortunately effect is the same, can't find image
roofik5
Posts: 23
Joined: 03 Jan 2021, 10:52

Re: ImageSearch or PixelSearch dont work at second monitor

05 Aug 2023, 15:10

I found a problem, when I have 150% scaling enabled on the computer (so as not to have small icons and windows on the monitor) the script does not work, with 100% it works. How to make it run at 150%?
Master_X
Posts: 33
Joined: 04 Aug 2023, 13:59

Re: ImageSearch or PixelSearch dont work at second monitor

05 Aug 2023, 15:55

I just tried imagesearch with 150% scaling, absolutely no problem.

Code: Select all

a::
ImageSearch, AusgabeVarX, AusgabeVarY, 1, 1, 1920, 1080, hehe.png
msgbox %AusgabeVarX% %AusgabeVarY%
Since you talk about different screens. Create new images with the correct screen attached. I noticed imagesearch and pixelsearch not always delivering the same colors/results on different pcs and or monitors. I think thats your problem.
roofik5
Posts: 23
Joined: 03 Jan 2021, 10:52

Re: ImageSearch or PixelSearch dont work at second monitor

05 Aug 2023, 16:04

Yes I've tried getting image from external screen but it's still not working. I cut image from my external screen try to find it and it doesn't work..
Master_X
Posts: 33
Joined: 04 Aug 2023, 13:59

Re: ImageSearch or PixelSearch dont work at second monitor

05 Aug 2023, 16:41

maybe try an exorbitant amount of pixels to search like 10000x10000 if this gives you the desired coordinates. But back to what you said. If you turn off scaling and everything else is the same your script works as you wish? So you used one screenshot of that 100% scale and in the other scenario another screenshot you made at 150% scale?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Rohwedder, Rxbie, tabr3 and 160 guests