Page 1 of 1

Help using Sysget + Imagesearch

Posted: 29 Jan 2023, 05:29
by ItsDucky
I'm trying to use sysget for variables the window will be on (Changed when needed as I use it on different computers and somtimes there is 3-4 or even 5 available).

Code: Select all

global MonitorNumber := 2 ; 1 = primary, 2 = secondary, etc etc.

SysGet, Mon, Monitor, %MonitorNumber%

Check:
ImageSearch, Ax, Ay, %MonLeft%, %MonRight%, %MonTop%, %MonBottom%, *40 Button.png
if !ErrorLevel
    ControlSend, ,{Space},Facebook
    sleep, % ran(1000,3020)
else
    Sleep, % ran(50,500)
Return
However it doesn't seem to ever detect the image unless I use numbers. I've also tried splitting the Sysget into multiple lines like

Code: Select all

global MonitorNumber := 2

SysGet, MonLeft, Monitor, %MonitorNumber%, 1
SysGet, MonTop, Monitor, %MonitorNumber%, 2
SysGet, MonRight, Monitor, %MonitorNumber%, 3
SysGet, MonBottom, Monitor, %MonitorNumber%, 4
I've used MSGBOX to print to see if it works, but it only works if I do "Monleftleft" etc etc, but Imagesearch still doesn't seem to like that.

The script works when I use

Code: Select all

ImageSearch, Ax, Ay, 2560, 419, 4480, 1499, *40 Button.png

Re: Help using Sysget + Imagesearch  Topic is solved

Posted: 29 Jan 2023, 07:00
by mikeyww
This is where the documentation helps you. See syntax.

Code: Select all

ImageSearch, OutputVarX, OutputVarY, X1, Y1, X2, Y2, ImageFile
Is monRight the same as Y1?

Re: Help using Sysget + Imagesearch

Posted: 29 Jan 2023, 07:40
by boiler
ItsDucky wrote: However it doesn't seem to ever detect the image unless I use numbers. I've also tried splitting the Sysget into multiple lines
You don’t split it into multiple lines. You do SysGet, …, Monitor, …, once, and then you add Left, Right, etc., to the base variable name you chose (whether it’s Mon, Mon2, Hello, etc.) to access the various variables. By “splitting”, you made four base variables named MonLeft, MonRight, etc., so then each of those has a Left, Right, etc., variable associated with them. So not only do you have MonLeftLeft, but also MonLeftRight, MonLeftTop, MonLeftBottom, MonRightLeft, MonRightLeft, MonRightTop, etc. You’ve made 16 variables instead of four. You’re supposed to do it once, like below, then access the four variables created from your base variable name:

Code: Select all

MonitorNumber := 2
SysGet, Mon2, Monitor, %MonitorNumber% ; Mon2
MsgBox, % Mon2Left "," Mon2Top "," Mon2Right "," Mon2Bottom

The reason it didn’t work for you is what mikeyww pointed out. You subsequently put them in the wrong places in the ImageSearch parameters.

Re: Help using Sysget + Imagesearch

Posted: 29 Jan 2023, 08:01
by ItsDucky
Oh wow, my first one works after I swapped them, silly mistake that just kept carrying over and lead me down a path of just trying obscure fixes.

It now detects the image.