Probably something to do with how I've set up ImageSearch coordinates in a direct manner for searching a region on my left (2nd of 3) monitor rather than trying to figure out prettier ways of doing it. But I'm still confused since WinActivate isn't doing anything to change my window positions so the search -should- work (in my head).
My monitor config, if it matters, is:
[#2 Left 1600x1200 landscape]
[#1 middle 2560x1600 landscape]
[#3 Right 1200x1600 portrait]
So the coordinates below are searching the 1600x1200 area on my left monitor.
[using AutoHotkey 1.1.26.01 on Win10_64 with BlueStacks 3N]
This works:
Code: Select all
#NoEnv
SetWorkingDir %A_ScriptDir%
;CoordMode, Mouse, Window
;CoordMode, Mouse, Screen
SendMode Input
#SingleInstance Force
SetTitleMatchMode 2
DetectHiddenWindows Off
#WinActivateForce
SetControlDelay 1
SetWinDelay 0
SetKeyDelay -1
SetMouseDelay -1
SetBatchLines -1
program = ahk_exe BlueStacks.exe
search_images = AutoHotkey_images\search
;WinActivate, %program%
;sleep 1000
;WinWaitNotActive, %program%
;WinActivate, %A_ScriptName%
WinMove, %program%,,IS_y2*-1,238,1600,1200 ; total hack to place the window as if it were maximized
; mostly just ignore, relative to my monitor position
/*
* Adjust the next 4 variables until you match on your screen.
... Example if using only a single 1920x1080 screen OR you're ok with this going on your PRIMARY monitor:
(With BlueStacks at 1600 width and top-left corner at top-left of your monitor):
IS_x1 = 0
IS_y1 = 0
IS_x2 = 1600
IS_y2 = 1080
*/
IS_x1 = -4160 ; locations on current virtual desktop, working
IS_y1 = 0
IS_x2 = -2560
IS_y2 = 1600
ImageSearch, FoundX, FoundY, IS_x1, IS_y1, IS_x2, IS_y2, %search_images%\map_select_a_location.png
if (ErrorLevel = 2) {
MsgBox Could not conduct the search.
} else if (ErrorLevel = 1) {
MsgBox Icon could not be found on the screen.
} else {
MsgBox The icon was found at %FoundX%x%FoundY%.
}
With the first WinActivate uncommented:
- I first tried to sleep for a second, no joy.
- I tried uncommenting WinWaitNotActive (manually clicking on another window after I was sure the WinActivate worked), no joy.
- Then re-commented WinWaitNotActive and uncommented to WinActivate for notepad++.exe right after the first WinActivate, so see if I could bring the main window fore, then activate a different window, but no joy.
- Additionally ... if I comment out the first WinActivate but leave the notepad++.exe activation in, the imagesearch also fails.
PS. I tried for awhile to get the ImageSearch and WinMove coordinates programatically with SysGet but got really frustrated. If someone bit on that part of the title, I'd appreciate the right method here.