Teckx

ImageSearch is not looking on 2nd monitor

4 posts in this topic

#1 ·  Posted

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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.

False Positive Reporter - Mass email all anti virus vendors with an attachment of your program for fast and easy whitelisting.

PortableApps.com App Creation Wizard  - A simple GUI-based Wizard for creating PortableApps.

SoundBoard - Play any song or sound you want at the press of a hotkey.

My GitHub Page: https://github.com/BetaLeaf

Share this post


Link to post
Share on other sites

#3 ·  Posted

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


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#4 ·  Posted

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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