Hi there,
I have a very boring task which I am hoping to automate with AHK, but I'm having a little trouble with the programming aspect. I have opened image file (full-screen) with a bunch of small circles on it, and I am trying to hover over the center of each circle and press Ctr + V (until every circle is done).
There is one aspect that is a little strange, though: because the image is in JPG format, each circle is aliased slightly differently. The difference is so slight, that you wouldn't know unless you zoomed in really far. Would this cause a problem for detection?
I think ImageSearch might work, but can it find every instance of the circle on the screen?
Thank you so much!
How can I use ImageSearch to find and click on all instances of an image?
Re: How can I use ImageSearch to find and click on all instances of an image?
Yes, transparency issues can matter in searching. The key with the search is that your reference image specified in the command must exactly match a visible area (or use the hue variation option). Short of a variation, a "difference so slight" is a difference.
Here is a "search all" function from boiler.
https://www.autohotkey.com/boards/viewtopic.php?p=391569#p391569
Here is a "search all" function from boiler.
https://www.autohotkey.com/boards/viewtopic.php?p=391569#p391569
Re: How can I use ImageSearch to find and click on all instances of an image?
Hi mikeyww,
Thank you for your help! If I'm trying to search the whole screen would I call the function like the code below?
Also, how would I use its returned value to hover and click on each image found?
Thank you again!
Thank you for your help! If I'm trying to search the whole screen would I call the function like the code below?
Code: Select all
4::
ImageSearchAll("C:\Users\Mi\Documents\example.jpg", , , , , 50)
Return
Thank you again!
Re: How can I use ImageSearch to find and click on all instances of an image?
https://docs.opencv.org/3.4/d4/d70/tutorial_hough_circle.html
If it is difficult for You to translate it to ahk, then it will be easier to write code on python.
If it is difficult for You to translate it to ahk, then it will be easier to write code on python.
Re: How can I use ImageSearch to find and click on all instances of an image?
Here is one example.
Code: Select all
Global places := []
CoordMode, Mouse
CoordMode, Pixel
image = %A_ScriptDir%\test.png
SoundBeep, 1500
imgFindAll(image, 500, 500, 800, 800)
SoundBeep, 1000
If !places.Count() {
MsgBox, 48, Nothing found, Nothing found.
Return
}
For k, v in places {
MouseClick,, v.1, v.2
Sleep, 300
}
imgFindAll(image, x1, y1, x2, y2) {
ImageSearch, x, y, x1, y1, x2, y2, %image%
If ErrorLevel
Return
places.Push([x, y]), size := imgSize(image)
imgFindAll(image, x + size.w, y, x2, y + size.h), imgFindAll(image, 0, y + size.h, x2, y2)
}
imgSize(img) { ; Returns an array indicating the image's width (w) and height (h),
; obtained from the file's properties
; https://www.autohotkey.com/boards/viewtopic.php?f=76&t=81665
SplitPath, img, fn, dir
objShell := ComObjCreate("Shell.Application")
objFolder := objShell.NameSpace(dir), objFolderItem := objFolder.ParseName(fn)
scale := StrSplit(RegExReplace(objFolder.GetDetailsOf(objFolderItem, 31), ".(.+).", "$1"), " x ")
Return {w: scale.1, h: scale.2}
}
Who is online
Users browsing this forum: Bing [Bot], mikeyww and 290 guests