Jump to content

ImageSearch is not looking on 2nd monitor


Recommended Posts

Is there a command I need to provide the script to tell it to look for images on both monitors?

 

It works perfect on the Main monitor but the secondary it doesn't look at. This usually wouldn't be a problem but applications like Outlook the new email window will change its spawn location

 

If I drag the email over to the main monitor the script will locate the image and continue

Link to comment
Share on other sites

First, you want to use _ImageSearchArea() to search instead of _ImageSearch(). You will need to get the resolution of your monitors/application you want to imagesearch on. This can be done with WinGetPos() for applications. For monitors, it gets a bit complicated. For the sake of covering all bases, you could search between -9999 to 9999. This will cause a lot of slowdown for your script as it tries to search such a large area (a lot of which a monitor may not even occupy). If you don't mind configuring the script per computer, then you will need to keep a few things in mind.

uc?id=0ByILJfRaEBfkZzBuV0QzZ0hObDA

Here is my multi monitor setup. It is pretty basic. The primary monitor is on the left and the secondary monitor is on the right. The top left pixel of the primary monitor is always 0,0. From that point, you simply measure the distance to the end of your secondary monitor. My setup is using 2560,1440 (1440p) as primary and 1920,1080 (1080p) as secondary. Since my primary monitor is the top left most of the monitors, my job becomes a bit easier. I know top left pixel on primary monitor is 0,0. Adding the width of both monitors together gives me a width of 4480. To get height, in this case, I simply measure the height of the tallest monitor, which is 1440. I would want to _ImageSearchArea within 0,0,4480,1440. This gets trickier when you have monitors to the left and above the primary monitor. Since we know the top left pixel of the primary monitor is 0,0, then anything above it or to the left of that pixel would be a negative number. For example, if my secondary monitor was to the left of primary monitor, instead of to the right as shown above, then my dimensions would be -1920,0,2560,1440. If the secondary monitor was above the primary monitor, then it would be 0,-1080,2560,1440. This all depends on how you position your monitors in the virtual space. It helps to look at your display settings/nvidia grid(surround) settings. This lets you visualize the virtual space windows uses for your monitors. Once you understand the virtual space, then it's just math. It's just like plotting points on an xy graph,  with the only difference is the y axis is inverted; negative becomes positive, positive becomes negative. Imagine plotting the top left, top right, bottom left, and bottom with its own dot, then draw a line to connect the dots so it becomes a rectangle. Hope this helps.

Edited by BetaLeaf
BTW, if anyone knows a better way to search multimonitors, please chime in, I would also love to know. Setting static values is not optimal.

 

 

Link to comment
Share on other sites

  • Moderators

Or, you could use the Outlook functions to check for new mail items, and avoid the ugliness of watching for a window pop up.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

As JLogan3o13 suggested: Use the OutlookEX UDF and events. Examples can be found by following the Examples link for Outlook in my signature.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...