Help using Sysget + Imagesearch Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ItsDucky
Posts: 2
Joined: 29 Jan 2023, 05:17

Help using Sysget + Imagesearch

Post by ItsDucky » 29 Jan 2023, 05:29

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

User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Help using Sysget + Imagesearch  Topic is solved

Post by mikeyww » 29 Jan 2023, 07:00

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?

User avatar
boiler
Posts: 16926
Joined: 21 Dec 2014, 02:44

Re: Help using Sysget + Imagesearch

Post by boiler » 29 Jan 2023, 07:40

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.

ItsDucky
Posts: 2
Joined: 29 Jan 2023, 05:17

Re: Help using Sysget + Imagesearch

Post by ItsDucky » 29 Jan 2023, 08:01

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.

Post Reply

Return to “Ask for Help (v1)”