ImageSearch not working on different displays

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ccapwell1
Posts: 8
Joined: 14 Nov 2017, 16:01

ImageSearch not working on different displays

14 Nov 2017, 16:30

Currently have a couple of ImageSearch AHKScripts for clicking on images within a GUI. This GUI is used on multiple screen sizes (laptops, larger monitors, vertical monitors, ect.). The scripts run without issues on my laptop and monitor as long as the scaling is set the same between each monitor ( 100% or 125%). I tried sharing these scripts with a friend so that he could use them on his laptop but the images cannot be found. We're using the same resolution settings (1920x1080), both laptops are using 100% scaling settings, both laptops are of the same make and very similar model but use slightly different graphics cards. (Intel HD Graphics 520 vs Intel HD Graphics 530). We can visually see a slight color difference on his monitor compared to mine and have tried to adjust this as close as possible but these changes do not seem to effect the imagesearch performance. We've tried copying ICM color profile files from one another laptops and still don't have luck. Is there a work-a-round anyone is aware of so we don't need to implement images from each display we use these scripts on? I've played with the "*N variation" parameters from *50-*200 without any luck as well. Any and all suggestions are greatly appreciated, thanks.

Code: Select all


IfWinExist, GUI
{    
    WinActivate  ; Automatically uses the window found above.

ImageSearch, foundX, foundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 %A_ScriptDir%\\..\Images\UsersIcon.png
if (!errorlevel){
Click %foundX%, %foundY%
}else if (ErrorLevel == 1){
MsgBox, Image cannot be found
}else{
MsgBox, Cannot Conduct Search
}

Sleep, 3500

ImageSearch, foundX, foundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 %A_ScriptDir%\\..\Images\ChangeUserIcon.png
if (!errorlevel){
Click %foundX%, %foundY%
}else if (ErrorLevel == 1){
MsgBox, Image cannot be found
}else{
MsgBox, Cannot Conduct Search
}

Sleep, 500

ImageSearch, foundX, foundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 %A_ScriptDir%\\..\Images\Administrator.png
if (!errorlevel){
Click %foundX%, %foundY%
}else if (ErrorLevel == 1){
MsgBox, Image cannot be found
}else{
MsgBox, Cannot Conduct Search
}

Sleep, 100

ImageSearch, foundX, foundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 %A_ScriptDir%\\..\Images\LogIn1.png
if (!errorlevel){
Click %foundX%, %foundY%, 1
}else if (ErrorLevel == 1){
MsgBox, Image cannot be found
}else{
MsgBox, Cannot Conduct Search
}



ImageSearch, foundX, foundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 %A_ScriptDir%\\..\Images\LogIn2.png
if (!errorlevel){
Click %foundX%, %foundY%
}else if (ErrorLevel == 1){
MsgBox, Image cannot be found
}else{
MsgBox, Cannot Conduct Search
}



ImageSearch, foundX, foundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 %A_ScriptDir%\\..\Images\LogIn3.png
if (!errorlevel){
Click %foundX%, %foundY%
}else if (ErrorLevel == 1){
MsgBox, Image cannot be found
}else{
MsgBox, Cannot Conduct Search
}


ImageSearch, foundX, foundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 %A_ScriptDir%\\..\Images\LogIn4.png
if (!errorlevel){
Click %foundX%, %foundY%
}else if (ErrorLevel == 1){
MsgBox, Image cannot be found
}else{
MsgBox, Cannot Conduct Search
}


Send {WheelDown 5}

Sleep, 500

ImageSearch, foundX, foundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 %A_ScriptDir%\\..\Images\Accept.png
if (!errorlevel){
Click %foundX%, %foundY%
}else if (ErrorLevel == 1){
MsgBox, Image cannot be found
}else{
MsgBox, Cannot Conduct Search
}
Send {WheelUp 3}
}




ExitApp

esc::ExitApp

KeypressGuy
Posts: 16
Joined: 17 Jul 2017, 16:55

Re: ImageSearch not working on different displays

14 Nov 2017, 16:49

If the images contain text that is being rendered by the OS or app, then ClearType settings can cause big differences from one user's settings to the next.
ccapwell1
Posts: 8
Joined: 14 Nov 2017, 16:01

Re: ImageSearch not working on different displays

15 Nov 2017, 08:04

KeypressGuy wrote:If the images contain text that is being rendered by the OS or app, then ClearType settings can cause big differences from one user's settings to the next.
We verified our ClearType settings were setup the same with no change with finding images. We also calibrated screens together as well to try and get them as equal as possible.
User avatar
Blackholyman
Posts: 1293
Joined: 29 Sep 2013, 22:57
Location: Denmark
Contact:

Re: ImageSearch not working on different displays

15 Nov 2017, 08:19

try to grab a screen shot from both systems and compare them on the same system with photoshop

the idea is to overlay the two images and see if every thing but the colors are exactly the same or not
Also check out:
Courses on AutoHotkey

My Autohotkey Blog
:dance:
ccapwell1
Posts: 8
Joined: 14 Nov 2017, 16:01

Re: ImageSearch not working on different displays

15 Nov 2017, 12:44

Blackholyman wrote:try to grab a screen shot from both systems and compare them on the same system with photoshop

the idea is to overlay the two images and see if every thing but the colors are exactly the same or not
We don't have access to photoshop unfortunately. We're pretty certain the colors are the only issue as the same image is shared between monitors with same resolution and scaling. Unless you have another idea of verifying this without photoshop.
User avatar
Blackholyman
Posts: 1293
Joined: 29 Sep 2013, 22:57
Location: Denmark
Contact:

Re: ImageSearch not working on different displays

15 Nov 2017, 14:05

Use gimp or a good free online photo editor

Your welcome to upload Them and post link to Them here and i’ll check Them as well
Also check out:
Courses on AutoHotkey

My Autohotkey Blog
:dance:
User avatar
boiler
Posts: 17384
Joined: 21 Dec 2014, 02:44

Re: ImageSearch not working on different displays

15 Nov 2017, 21:31

The best thing to do to compare images is to actually compare the RGB values of pixels from the same relative spot in the images on the two computers. The pixels could look different visually depending on monitor settings, etc., but that is irrelevant because all that matters is whether the numbers that make up the as-displayed images are the same on a pixel-by-pixel basis. That will tell you for sure if they are rendering text differently or whatever. One good way to do that is to turn on a magnifier and use the Window Spy tool.

Another approach is to write a quick script using PixelGetColor to scan the area of the image and record all the RGB data into a text file. Then you can compare the text files created on the two different computers.
ccapwell1
Posts: 8
Joined: 14 Nov 2017, 16:01

Re: ImageSearch not working on different displays

16 Nov 2017, 09:48

Blackholyman wrote:Use gimp or a good free online photo editor

Your welcome to upload Them and post link to Them here and i’ll check Them as well
Thank you, that would be a huge help

Here is a screenshot from system 1:

https://s33.postimg.org/yo061jjlb/System1.png

Here is a screenshot from system 2:

https://s33.postimg.org/sn2h4j9un/System2.png

Both the same exact image, screenshotted separately on individual systems.
Last edited by ccapwell1 on 16 Nov 2017, 11:36, edited 1 time in total.
ccapwell1
Posts: 8
Joined: 14 Nov 2017, 16:01

Re: ImageSearch not working on different displays

16 Nov 2017, 09:49

boiler wrote:The best thing to do to compare images is to actually compare the RGB values of pixels from the same relative spot in the images on the two computers. The pixels could look different visually depending on monitor settings, etc., but that is irrelevant because all that matters is whether the numbers that make up the as-displayed images are the same on a pixel-by-pixel basis. That will tell you for sure if they are rendering text differently or whatever. One good way to do that is to turn on a magnifier and use the Window Spy tool.

Another approach is to write a quick script using PixelGetColor to scan the area of the image and record all the RGB data into a text file. Then you can compare the text files created on the two different computers.
Thanks for the response. We're pretty certain the pixels are slightly different. We thought using the *N feature would make up for these differences. If this is the case maybe the best way to deal with this is to search for both images and click whatever one is found?
User avatar
boiler
Posts: 17384
Joined: 21 Dec 2014, 02:44

Re: ImageSearch not working on different displays

16 Nov 2017, 10:00

Searching for either image seems the way to go.

You referred to those to images as photos and screenshots. Are they actual screenshots? If so, why are they different sizes? That's a show stopper right there if you think they both with be found by the same ImageSearch. They are nowhere close to the same image if they are different sizes, and comparing the colors is a useless exercise.
ccapwell1
Posts: 8
Joined: 14 Nov 2017, 16:01

Re: ImageSearch not working on different displays

16 Nov 2017, 11:36

boiler wrote:Searching for either image seems the way to go.

You referred to those to images as photos and screenshots. Are they actual screenshots? If so, why are they different sizes? That's a show stopper right there if you think they both with be found by the same ImageSearch. They are nowhere close to the same image if they are different sizes, and comparing the colors is a useless exercise.
They are screenshots of the same image. We didn't think the point was about the size of the screenshot but rather the color differences between the two. We would like to not have to include both images to search for either but rather have a set image that works on multiple displays. Screenshots were taken to show the difference in color from monitor to monitor. The goal is to use one image that can be found across multiple displays.
User avatar
boiler
Posts: 17384
Joined: 21 Dec 2014, 02:44

Re: ImageSearch not working on different displays

16 Nov 2017, 11:45

If they're different sizes, they really aren't screenshots of the same image and color doesn't matter at all. They are two totally different images and could never both be found by using ImageSearch and the same reference image. ImageSearch looks for an exact pixel-for-pixel match (within allowable variance), and when pictures are different sizes, the pixels aren't comparable at all.
ccapwell1
Posts: 8
Joined: 14 Nov 2017, 16:01

Re: ImageSearch not working on different displays

16 Nov 2017, 12:00

boiler wrote:If they're different sizes, they really aren't screenshots of the same image and color doesn't matter at all. They are two totally different images and could never both be found by using ImageSearch and the same reference image. ImageSearch looks for an exact pixel-for-pixel match (within allowable variance), and when pictures are different sizes, the pixels aren't comparable at all.
This is understood. The fact is that we would like to only use one of these screenshots. If its a screenshot from the GUI we crop out the surrounding black or white area surrounding the image. So ideally, only one of these screenshot will be used and it would be the same size because it's the same screenshot. So ignore the size for the time being as we would like to take one of these screenshots for finding the same image on both monitors.
ccapwell1
Posts: 8
Joined: 14 Nov 2017, 16:01

Re: ImageSearch not working on different displays

16 Nov 2017, 14:01

For whatever reason it seems to only be an issue with this one laptop. Have used my scripts on 4 separate laptops, monitors, desktop pcs, ect. But why would one display not be able to find these images when resolution, scaling, and all above are the same
KeypressGuy
Posts: 16
Joined: 17 Jul 2017, 16:55

Re: ImageSearch not working on different displays

16 Nov 2017, 16:25

Microsoft has a very informative blog at https://blogs.technet.microsoft.com/ask ... indows-10/ which has pretty much convinced me to give up "If at first I don't succeed" with cross-screen image matching. Boils down to user-perception now trumps pixel-exactness.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot] and 203 guests