ShinsImageScanClass is an AutoHotKey class designed for user freindliness and performance in mind, capable of searching for images and pixels extremely fast and also with background window support it's versatile and lightweight, with no additional dependancies. It also supports 32 and 64 bit, and now supports AutoHotkey V2 as well.
#Image....................Find an image; Returns 1 on success and updates returnX and returnY variables; 0 otherwise
Image(image, variance=0, ByRef returnX=0, ByRef returnY=0, centerResults=0, scanDir:=0)
#ImageRegion..............Find an image in a specified region; Returns 1 on success and updates returnX and returnY variables; 0 otherwise
ImageRegion(image, x1, y1, w, h, variance=0, ByRef returnX=0, ByRef returnY=0, centerResults=0, scanDir:=0)
#ImageCount...............Find the amount of images; Returns count of images
ImageCount(image, variance=0)
#ImageCountRegion.........Find the amount of images in a specified region; Returns the count of images inside the region
ImageCountRegion(image, x1, y1, w, h, variance=0)
#ImageClosestToPoint......Finds the closest image to a given position; Returns 1 on success and updates returnX and returnY variables; 0 otherwise
ImageClosestToPoint(image, pointX, pointY, variance=0, byref returnX=0, byref returnY=0, centerResults=0, maxRadius=9999)
#ImageArray...............Finds all images; Returns 1 on success and updates the array variable to contain all image positions; 0 otherwise
ImageArray(image, byref array, variance=0, centerResults=0)
#ImageArrayRegion.........Finds all images in a specified region; Returns 1 on success and updates the array variable to contain all image positions; 0 otherwise
ImageArrayRegion(image, byref array, x1, y1, w, h, variance=0, centerResults=0)
#Pixel....................Find a pixel; Returns 1 on success and updates returnX and returnY variables; 0 otherwise
Pixel(color, variance=0, ByRef returnX=0, ByRef returnY=0, scanDir:=0)
#PixelRegion..............Find a pixel in a specified region; Returns 1 on success and updates returnX and returnY variables; 0 otherwise
PixelRegion(color, x1, y1, w, h, variance=0, byref returnX=0, byref returnY=0, scanDir:=0)
#PixelCount...............Finds the count of pixels; Returns the count of pixels
PixelCount(color, variance=0)
#PixelCountRegion.........Finds the count of pixels in a specified region; Returns the count of pixels in that region
PixelCountRegion(color, x1, y1, w, h, variance=0)
#PixelCountRadius.........Finds the count of pixels in a specified radius; Returns the count of pixels in that radius
PixelCountRadius(color, pointX, pointY, radius, variance=0)
#PixelArrayRegion.........Finds all matching pixels in a specified region; Returns the count of pixels in that region and updates the array
PixelArrayRegion(color, byref array, x1, y1, w, h, variance=0, maxResults=1000) {
#PixelPosition............Checks a pixel at a specified position; Returns 1 on color match; 0 otherwise
PixelPosition(color, pointX, pointY, variance=0)
#GetPixel.................Gets the pixel at a specified position; Returns pixel color on success; 0 otherwise
GetPixel(x, y)
#SaveImage................Save the current pixel buffer to a png image; Allows for saving specific areas as well.
SaveImage(name, x:=0, y:=0, w:=0, h:=0)
#Click....................Clicks at a position, supports background windows when possible
Click(pointX, pointY, button:="left")
#ClickDrag................Clicks and drags from two positions, supports background windows when possible
ClickDrag(pointX1, pointY1, pointX2, pointY2, button:="left")
#ClickRegion.............Clicks randomly inside a defined region
ClickRegion(pointX, pointY, w, h, button:="left")
#GetImageDimensions......Gets the width and height of an image used for searching
GetImageDimensions(image, byref w, byref h)
# Image() ImageRegion() Pixel() and PixelRegion() support 8 different scan direction:
# LRTB = Left to Right, from the Top to the Bottom (Default)
# LRBT = Left to Right, from the Bottom to the Top
# RLTB = Right to Left, from the Top to the Bottom
# RLBT = Right to Left, from the Bottom to the Top
# TBLR = Top to Bottom, from the Left to the Right
# TBRL = Top to Bottom, from the Right to the Left
# BTRL = Bottom to Top, from the Right to the Left
# BTLR = Bottom to Top, from the Left to the Right
When searching for images, using source files without transparency will generally be faster
Searching for all images such as ImageCount() etc. will take significantly longer when using color variance; when possible try to avoid using color variance if speed is a concern
I've only tested on my end and can confirm it works for me using 32/64 bit AHK on windows 10
if it doesn't work for you let me know, I may be able to help, or may not just depends.
Thanks for stopping by! If you really enjoy my code and want to make a small donation, then here's a link! https://www.buymeacoffee.com/Spawnova
I will continue to provide code, and support released classes regardless of any monetary support, and I'd rather none is given if you are not comfortably in a position to do so!