I'm trying to search images on a client hiding behind another windows using simple function that I found but I seem to have some issues with it. I'm also using Gdip_Imagesearch with it.
Code: Select all
search_img(image,hwnd, byref vx, byref vy) {
pToken:=Gdip_Startup()
SetWorkingDir %A_ScriptDir%
pBitmapHayStack:=Gdip_BitmapFromhwnd(hwnd)
pBitmapNeedle:=Gdip_CreateBitmapFromFile(image)
if Gdip_ImageSearch(pBitmapHayStack,pBitmapNeedle,list,0,0,0,0,50,,1,1)
{
StringSplit, LISTArray, LIST, `,
vx:=LISTArray1
vy:=LISTArray2
Gdip_DisposeImage(pBitmapHayStack), Gdip_DisposeImage(pBitmapNeedle)
Gdip_Shutdown(pToken)
return true
}
else
{
Gdip_DisposeImage(pBitmapHayStack), Gdip_DisposeImage(pBitmapNeedle)
Gdip_Shutdown(pToken)
return false
}
}
Code: Select all
ImageSearch, x, y, %pos_x%, %pos_y%, %x_right%, %y_bottom%, *50 %A_ScriptDir%\Image\victory%A_index%.bmp
Code: Select all
WinGet,Nox,ID, NoxPlayer
loop, 4{
if(Search_img(%A_ScriptDir%\Image\victory%A_index%.bmp, Nox,x,y)){
tooltip hi %x% %y% %A_index%
sleep, 1000
}
else{
tooltip bye
sleep, 1000
}
}
1. All of my images r under a folder called "Image". When I tried to add location at search_img function, it says it's illegal expression. It only seems to accept file names with "" in it.
2. Some of my ImageSearch line have %A_index% so it can go through loop to compare different number of images. How do I also incorporate that into Search_img function?
3. Even if I have a wrong image to compare, it still says "hi" according to the script. How I make it return "bye" if the given image is not on the client that I asked to search?