ImageSearch 2-nd display

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Siskin
Posts: 3
Joined: 23 Jun 2018, 13:56

ImageSearch 2-nd display

23 Jun 2018, 14:03

Hello everyone.

I have a problem with ImageSearch... no matter what I do, it cannot detect a image on the second extended non-primary display. It works flawlessly on the main display though. I reduced the code to a basic working example that should work but doesn't. Any assistance would be highly appreciated.

Code: Select all

SetWorkingDir %A_ScriptDir% 

CoordMode, ToolTip, screen
CoordMode, Mouse, screen
CoordMode, Pixel, screen

SysGet, VirtualScreenWidth, 78
SysGet, VirtualScreenHeight, 79

SysGet, VirtualScreenLeft, 76
SysGet, VirtualScreenTop, 77


	ImageSearch, FoundX, FoundY, VirtualScreenLeft, VirtualScreenTop ,VirtualScreenLeft+VirtualScreenWidth, VirtualScreenTop+VirtualScreenHeight, *50 testpic.bmp 
	if ErrorLevel = 2
		MsgBox Could not conduct the image search.
	else if ErrorLevel = 1
	{
		MsgBox Image not found
		ExitApp
		Return
	}
	MsgBox %FoundX% %FoundY%
ExitApp
Return
Test image used (opened in image viewer, original size no zoom, is detected on primary monitor but on secondary) https://i.gyazo.com/914d4233f85fb45a5ae ... c82163.png
Gibbons
Posts: 93
Joined: 20 Sep 2016, 20:39

Re: ImageSearch 2-nd display

23 Jun 2018, 15:44

If you are trying to look ONLY on the second screen, then I can't help you. If you want to find it on any screen then just Window spy to find your largest x and y number on either screen, then just do and image search to the largest x and y number.

ImageSearch, FoundX, FoundY, 0, 0, largest x, largest y, testpic.bmp

that is what I use with success.
Siskin
Posts: 3
Joined: 23 Jun 2018, 13:56

Re: ImageSearch 2-nd display

23 Jun 2018, 16:25

Choosing the corect search area is not the problem my friend. The problem upon further tests seems to be that the imagesearch function does not like high numbers. Looks like a bug. If I make the other monitor primary and the virtual screen starts at negative coordinates, leaving only the second screen with positive coordinates, it works.
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: ImageSearch 2-nd display

23 Jun 2018, 16:27

Run this:

Code: Select all

SysGet, Mon2, Monitor, 2
MsgBox, Left: %Mon2Left% -- Top: %Mon2Top% -- Right: %Mon2Right% -- Bottom %Mon2Bottom%.
Here is how i tested which works fine:

Code: Select all

#NoEnv

CoordMode, Mouse, Screen
CoordMode, Pixel, Screen

SysGet, Mon2, Monitor, 2

ImageSearch, foundx, foundy, Mon2Left, Mon2Top, Mon2Right, Mon2Bottom, test.png
MsgBox % ErrorLevel

ExitApp
HTH
Siskin
Posts: 3
Joined: 23 Jun 2018, 13:56

Re: ImageSearch 2-nd display

25 Jun 2018, 11:51

My setup is Monitor 2 primary, leftmost. Monitor 1 extended desktop smaller and to the right of monitor 2, aligned at top. With your code it works on monitor 2 (primary), which works with any other code sample as intended. But once I move the picture to monitor 1 and change "SysGet, Mon2, Monitor, 2" to "SysGet, Mon2, Monitor, 1" again, it doesn't work.

The problem seems to be that ImageSearch doesn't like it if monitor 1 is not primary. I cannot change which is 1 and which is 2, 1 is laptop screen, 2 is hdmi cable connection to external monitor.
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: ImageSearch 2-nd display

25 Jun 2018, 12:10

Strange i cant get it to not work. My primary display is monitor 2.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Joey5 and 267 guests