Hi there everyone! I am a newish user who has not had a lot of success with trying to get ImageSearch to work for what I am aiming for. I just want it to find a small box with the word "Leave" in it. I've included my code below along with the image I am searching with atm. Right now with the code as is, I ONLY get my error from line 20. If I change the *n to a higher number it does find things, but it totally random where the mouse moves to and it seems to be different each run. I am running this program from webex and the goal is to have a 1 button that we can leave conversations with. Right now we open more then 200 a day and having to manually close them gets a bit much. The commented out lines 12-14 works fine for anyone that is using MY screen res, but I wanted to make this so anyone on my team can use it. The second annotation is what normally pops up after line 9, but some times there is a missing line of "copy space link" so I can't just do it by set pixels. And the issue of being close to the bottom of the screen moves the rclick screen up rather then down also breaking what I have.
Any help on how to improve this would be awesome!
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
SetTitleMatchMode, 2
#IfWinActive Webex
F1::
Click, Right
MouseGetPos, X, Y
Sleep 300
;MouseMove, (30+X), (Y+240), 50
; Click
;MouseMove, X, Y
IfNotExist, leave.png
MsgBox Error: Your file either doesn't exist or isn't in this location.
CoordMode Pixel
ImageSearch FoundX, FoundY, X-50, Y-300, X+50, Y+300, *20 leave.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%.
MouseMove, FoundX, FoundY
return
#IfWinActive Webex
F2::
MouseGetPos, xpos, ypos
MsgBox, The cursor is at X%xpos% Y%ypos%.
- leave.png (820 Bytes) Viewed 379 times
- Annotation 2022-07-06 225242.png (5.47 KiB) Viewed 379 times