1,2주정도 계속 구글링만하다가 안되서 질문합니다 ㅠ
유니코드 32비트 64비트 gdip_all 전부 다 받아서 해봤지만
항상 -1,-1을 리턴합니다..
해당 프로세스외의 다른 프로세스에서는 잘 되구요.
이런경우는 방법이 없는건가요?
--------------------------
#include Gdip.ahk
ImageSearch_Inactive(Title, ImgFileName)
{
If !pToken := Gdip_Startup()
{
MsgBox, 48, gdiplus error!, Gdiplus failed to start.
ExitApp
}
OnExit, Exit
pBitmapHayStack := Gdip_BitmapFromHWND(hwnd := WinExist(Title))
pBitmapNeedle := Gdip_CreateBitmapFromFile(ImgFileName)
Width1 := Gdip_GetImageWidth(pBitmapHayStack), Height1 := Gdip_GetImageHeight(pBitmapHayStack)
Width2 := Gdip_GetImageWidth(pBitmapNeedle), Height2 := Gdip_GetImageHeight(pBitmapNeedle)
E1 := Gdip_LockBits(pBitmapHayStack, 0, 0, Width1, Height1, Stride1, Scan01,BitmapData1)
E2 := Gdip_LockBits(pBitmapNeedle, 0, 0, Width2, Height2, Stride2, Scan02,BitmapData2)
MCode(Gdip_ImageSearch, "83EC148B4424309983E20303C28BC88B442434995383E2035503C2C1F80256C1F902837C24"
. "30005789442420C7442410000000000F8EBE0000008B5C24288B7C24388D048D00000000894424188B442430895C241CE"
. "B098DA424000000008BFFC74424440000000085C07E6D895C24148B6C242CC7442440000000008D6424008B4C24403B4C"
. "243C0F8D8600000033C985FF7E158BD58BF38B063B02751F4183C20483C6043BCF7CEF8B442420035C2418FF44244003C"
. "003C003E8EBC38B4C24448B5C24148B4424304183C3043BC8894C2444895C24147C978B4C24108B5C241C035C2418413B"
. "4C2434894C2410895C241C0F8C68FFFFFF8B5424488B44244C5F5E5DC702FFFFFFFFC700FFFFFFFF5B83C414C38B4C244"
. "48B5424488B44244C5F495E890A8B4C24085D89085B83C414C3")
Time1 := A_TickCount
VarSetCapacity(x, 8, 0), VarSetCapacity(y, 8, 0)
Loop, 100
DllCall(&Gdip_ImageSearch, "uint", Scan01, "uint", Scan02, "int", Width1, "int", Height1, "int", Width2, "int", Height2, "int", Stride1, "int", Stride2, "int*", x, "int*", y)
MsgBox, % "Time for 100 searches: " A_TickCount-Time1 "ms`nx: " x "`ny: " y ""
;x := " x "
;y := " y "
; Pos := x|y<<16
Gdip_UnlockBits(pBitmapHayStack,BitmapData1), Gdip_UnlockBits(pBitmapNeedle,BitmapData2)
Gdip_DisposeImage(pBitmapHayStack), Gdip_DisposeImage(pBitmapNeedle)
return
}
MCode(ByRef code, hex)
{
VarSetCapacity(code, StrLen(hex)//2)
Loop % StrLen(hex)//2 ;%
NumPut("0x" SubStr(hex, 2*A_Index-1, 2), code, A_Index-1, "char")
}
F1::
ImageSearch_Inactive("test","test.bmp")
return
F2::
Exit:
Gdip_Shutdown(pToken)
ExitApp
return
OS가 윈도우 8.1이상이라면 아래와 같이 해보시기 바랍니다.
Gdip.ahk 또는 gdip_all.ahk에서 아래 함수를 찾습니다.
Gdip_BitmapFromHWND(hwnd)
{
WinGetPos,,, Width, Height, ahk_id %hwnd%
hbm := CreateDIBSection(Width, Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
PrintWindow(hwnd, hdc) => PrintWindow(hwnd,hdc,"0x2") 로 변경
pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
return pBitmap
}
붉은 글씨부분 변경해보시기 바랍니다.