Imagesearch non-rectangular extended desktop

Get help with using AutoHotkey and its commands and hotkeys
Posts: 32
Joined: 25 Jan 2015, 22:57

Imagesearch non-rectangular extended desktop

13 Jul 2018, 10:22

I have a 5 monitor setup, with 4 monitors across and 1 monitor placed above the 2nd monitor from the left. So the desktop is non-rectangular. This is causing problems with imagesearch.

I've tried this:

Code: Select all

screenWidth = 1920 screenHeight = 1080 #F4:: ; click image CoordMode, Pixel, Relative CoordMode, Mouse, Relative ImageSearch, X, Y, 0, 0, %screenWidth%, %screenHeight%, *100, %imageToSearchFor% Sleep, 100 MouseClick, left, X, Y return
This finds the image some days, and some days it does not. And when it's not finding the image, if I move the app in which I'm searching for the image to another screen, that sometimes works. Whether the image is being found or not, imagesearch returns the same coordinates across repeated attempts (whether those coordinates are correct or not).

I then discovered SysGet, and I tried this:

Code: Select all

#F4:: ; click image CoordMode, Pixel, Screen CoordMode, Mouse, Screen SysGet, VirtualScreenWidth, 78 SysGet, VirtualScreenHeight, 79 SysGet, VirtualScreenLeft, 76 SysGet, VirtualScreenTop, 77 ImageSearch, X, Y, VirtualScreenLeft, VirtualScreenTop, VirtualScreenLeft+VirtualScreenWidth, VirtualScreenTop+VirtualScreenHeight, *100, %imageToSearchFor% Sleep, 100 MouseClick, left, X, Y return
Not only does this not find the image, the coordinates it returns are not consistent across repeated attempts. I think this has to do with the non-rectangular desktop. VirtualScreenLeft, VirtualScreenTop are not coordinates that actually exist on this desktop. I.e., VirtualScreenLeft refers to the left edge of the leftmost monitor, and VirtualScreenTop refers to the top edge of the one monitor that is above 2nd monitor from the left.

Any suggestions on how I can get imagesearch to return the correct coordinates?

I'm a bit confused as to why the first code doesn't always work. If CoordMode Pixel and Mouse are both set to relative, then imagesearch and mouseclick are relative to the active screen, so as long as the app in which I'm searching for the image is the active window, why does it matter if there are other screens or how many there are or where they are placed?

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 54 guests