Problems With tics GDI ImageSearch

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Roonyroo
Posts: 36
Joined: 29 Jan 2014, 20:29

Problems With tics GDI ImageSearch

16 Mar 2014, 15:01

Post edited ...

I've finally found a working script, but replacing

pBitmapHayStack := Gdip_BitmapFromHWND(hwnd := WinExist("WindowName"))

with

pBitmapHayStack := Gdip_CreateBitmapFromFile(image)

Returns an error ...

You need tics library http://www.autohotkey.com/board/topic/7 ... ntry524852

Place & name the library Gdip_ImageSearch, under a directory called lib in your installation directory

My script

Code: Select all



image=%A_ScriptDir%\T-002-haystack-novo.png
image2=%A_ScriptDir%\T-002-needle-novo.png

IfNotExist, %image%   ; start with a know image, the Deutsch Flag icon on http://www.autohotkey.com
{
  UrlDownloadToFile, http://www.autohotkey.com/docs/images/DE.gif, %image%
  msgbox,,, d/l complete, 1
}

gui,margin, 0,0
gui, add, picture,x15 y15, %image%
gui, show, w300 h200 , WindowName

sleep, 1000

pToken := Gdip_Startup()
pBitmapHayStack := Gdip_CreateBitmapFromFile(image)
pBitmapNeedle := Gdip_CreateBitmapFromFile(image2)
Gdip_SaveBitmapToFile(pBitmapHayStack, "pBitmapHayStack.png")
Gdip_SaveBitmapToFile(pBitmapNeedle, "pBitmapNeedle.png")
if !Gdip_ImageSearch(pBitmapHayStack, pBitmapNeedle, x, y)

mousemove %x%,%y%

MsgBox, %x% %y%

Gdip_DisposeImage(pBitmapHayStack), Gdip_DisposeImage(pBitmapNeedle)
Gdip_Shutdown(pToken)
exitapp





The original working script

Code: Select all

image=DE.gif
IfNotExist, %image%   ; start with a know image, the Deutsch Flag icon on http://www.autohotkey.com
{
  UrlDownloadToFile, http://www.autohotkey.com/docs/images/DE.gif, %image%
  msgbox,,, d/l complete, 1
}

gui,margin, 0,0
gui, add, picture,x15 y15, %image%
gui, show, w300 h200 , WindowName

sleep, 1000

pToken := Gdip_Startup()
pBitmapHayStack := Gdip_BitmapFromHWND(hwnd := WinExist("WindowName"))
pBitmapNeedle := Gdip_CreateBitmapFromFile(image)
Gdip_SaveBitmapToFile(pBitmapHayStack, "pBitmapHayStack.png")
Gdip_SaveBitmapToFile(pBitmapNeedle, "pBitmapNeedle.png")
if !Gdip_ImageSearch(pBitmapHayStack, pBitmapNeedle, x, y)

MsgBox, %x% %y%

Gdip_DisposeImage(pBitmapHayStack), Gdip_DisposeImage(pBitmapNeedle)
Gdip_Shutdown(pToken)
exitapp

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: apeironn, Google [Bot], peter_ahk and 322 guests