I don't understand what you mean by "100,100 is top left region I want to search and I restrict it to 300,200 by a rectangle." How does a single coordinate 100,100 define a region? And what do you mean by restricting it to 300,200 by a rectangle? By using the rectangle defined by
100, 100, 300, 200 as you did in your function call, you would be looking for your reference image to be found somewhere within the screen area bound by the upper-left coordinate 100,100 and the lower-right coordinate of 300,200. Your reference image must be found wholly within that area of the screen.
And no, that's not how you would click on it. As I described, the results are in an array, and each element of that array has a two-element array with x and y keys. Assuming the result is the first or only result (remember, this function is meant for when multiple instances are expected to be found, or else you might as well use regular ImageSearch), the way you would click on it with the right mouse button would be one of the following:
Using regular Click, it can look complex because you have to force an expression since Click really only has one parameter that gets parsed by the interpreter even though the various parts can be separated by commas (don't worry if you don't know what that means):
Code: Select all
Lines := ImageSearchAll("E:\Dropbox\Screenshots\AutoHotkey_2021-08-04_12-10-21.png", 100, 100, 300, 200, 0)
Click, % Lines.1.x "," Lines.1.y " " Right
It may be easier to understand using MouseClick since it has separate parameters for x and y that can be expressions:
Code: Select all
Lines := ImageSearchAll("E:\Dropbox\Screenshots\AutoHotkey_2021-08-04_12-10-21.png", 100, 100, 300, 200, 0)
MouseClick, Right, Lines.1.x, Lines.1.y
Using built-in ImageSearch, which is what you would do when you only expect one result or when you want to use the first instance that would be found:
Code: Select all
ImageSearch, LineX, LineY, 100, 100, 300, 200, E:\Dropbox\Screenshots\AutoHotkey_2021-08-04_12-10-21.png
Click, %LineX%, %LineY%, Right
None of the above include checking that something was actually found before attempting to click on it, but that's easy to add.