ImageSearch issue with MS Wireless Display Adapter

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
kbh81a
Posts: 2
Joined: 13 May 2021, 10:27

ImageSearch issue with MS Wireless Display Adapter

13 May 2021, 14:08

Code: Select all

#SingleInstance force

^r::
CoordMode, Pixel , Window
ImageSearch, resX, resY, 0, 0, 400, 400, *150 C:\Users\abc\Desktop\Notepad144.png
msgbox % "Result Window: x=" . resX . " y=" . resY . "`nErrorLevel=" . ErrorLevel . "`n`n" . "AHK Screeen DPI=" . A_ScreenDPI
return
I am trying to get an ImageSearch that did work fine for month with a cabled external monitor to now work on an external TV connected via the MS Wireless Display Adapter.
Problem: the above code snippet to identify the notepad is not working on a connected Microsoft Wireless Display Adapter (V.2.0.8442) in extended monitor configuration.
It IS working fine on that same setup / monitor when I use the Windows 10 Display Settings to make the TV monitor ID the "Make this my main display".
It IS also working fine regardless of the main display property on a different (cabled) external monitor.
All displays used have the same scaling factor (150% for me) and I tried the PNG file screenshot from both monitors - identical file and thus same effect, too.

Any idea how to solve the issue would be welcome.
Attachments
Notepad144.png
Notepad144.png (958 Bytes) Viewed 188 times
User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: ImageSearch issue with MS Wireless Display Adapter

13 May 2021, 18:10

When Windows’ scaling factor is at 150%, it stretches/blends graphics when it displays them, such that it no longer represents the underlying graphical elements, and it does it in a way that is not repeatable, typically. Imagine taking a very simple 2 pixel by 2 pixel image and now you want to display it over a 3 pixel by 3 pixel area. Each pixel will become sort of a smudged average value of the nearest neighboring pixels of the 2x2 image such that none of the pixels match any pixels from the original. That fundamentally changes what’s being displayed.

Even though you’re using the same scaling factors on both displays, it often doesn’t matter because it will be rendered differently at different times. This is a Windows issue, not an AHK issue. Try taking a snapshot of each displayed image and view it on a pixel-by-pixel basis in MS Paint zoomed to the max. See if you can identify some differences. Use the Window Spy tool to check the actual color values if necessary.

Perhaps since they’re both at the same scaling factor, you might be able to get away with using a large enough allowable variation setting in the ImageSearch command. Try higher and higher values until it (hopefully) finds it.
kbh81a
Posts: 2
Joined: 13 May 2021, 10:27

Re: ImageSearch issue with MS Wireless Display Adapter

14 May 2021, 07:18

I understand the logic, but I have tried all of these before posting. Scaling is a big issue when working on different monitors, which led me to take a screenshot file to use with ImageSearch for each display setting.
I have zoomed in and compared pixel-by-pixel (exact tie) and have also had the variations up to N 250, without same effect. I also had the idea to double check with variation 255 to test a fundamental problem, but as expected: already the top left position of the search area is a match then.
I would totally understand that some deeper Win10, Graphics driver whatever issue does not allow AHK ImageSearch to work properly on that setting - BUT as I have written, as soon as this TV with MSWirelessDisplayAdapter becomes the main monitor, it works. That is what makes no sense to me and triggered my question and eager to get the script working.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, Google [Bot], Joey5, RandomBoy, wpulford and 392 guests