i am new to this forum, please do excuse me for any mistakes.
Gdip_ImageSearch, i am trying to find a image count and position, unable to find all instances, please help.
thanks in advance.
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.
#Persistent
#SingleInstance force
SetTitleMatchMode, Slow
SetTitleMatchMode, 2
SetBatchLines, -1
CoordMode Pixel, Screen
;~ #Include *i Gdip_All.ahk
#Include *i Gdip_ImageSearch.ahk
CapsLock::
If !pToken := Gdip_Startup()
{
MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
ExitApp
}
l := ""
pneedle :=Gdip_CreateBitmapFromFile("1.PNG")
Gdip_GetImageDimensions(pneedle , wn, hn)
phaystack:=pBitmap :=bmpHaystack := Gdip_BitmapFromScreen()
;~ phaystack:=pBitmap :=bmpHaystack := Gdip_CreateBitmapFromFile("All.PNG")
Gdip_GetImageDimensions(phaystack , wh, hh)
pGraphics:=Gdip_GraphicsFromImage(phaystack)
pBrush:=Gdip_BrushCreateSolid(0xff000000)
t:=a_tickcount
loop, 10 ;just to be safe
{
Gdip_ImageSearch(phaystack ,pneedle,list,0,0,wh,hh,10,0x000000,1,0) ; also tried Trans 0xFFFFFF
if !regexmatch(list,"\d")
break
l .=list "`n"
pos:=strsplit(list,",")
}
msgbox % "time= " a_tickcount-t "ms`n" l
Gdip_DisposeImage(phaystack)
Gdip_DisposeImage(pneedle)
Gdip_Shutdown(pToken)
return