I think you can replace screen data with image files like this, but I haven't tested:c7aesa7r wrote: ↑16 Jul 2020, 05:54do someone know if is possible to search inside a pbitmap instead searching for the text on screen?
i tried edit here, but did not workCode: Select all
if (id) and !(w<1 or h<1) { ;hDC2:=DllCall("GetDCEx", Ptr,id, Ptr,0, "int",3, Ptr) ;hDC2 := Gdip_BitmapFromHWND(id) hDC2 := Gdip_CreateBitmapFromFile("C:\Users\User\Documents\x.png") ; DllCall("BitBlt",Ptr,mDC,"int",x-zx,"int",y-zy,"int",w,"int",h , Ptr,hDC2, "int",x-wx, "int",y-wy, "uint",0x00CC0020|0x40000000) DllCall("ReleaseDC", Ptr,id, Ptr,hDC2) }
Code: Select all
/*
if (hBM) and !(w<1 or h<1)
{
win:=DllCall("GetDesktopWindow", Ptr)
hDC:=DllCall("GetWindowDC", Ptr,win, Ptr)
mDC:=DllCall("CreateCompatibleDC", Ptr,hDC, Ptr)
oBM:=DllCall("SelectObject", Ptr,mDC, Ptr,hBM, Ptr)
DllCall("BitBlt",Ptr,mDC,"int",x-zx,"int",y-zy,"int",w,"int",h
, Ptr,hDC, "int",x, "int",y, "uint",0x00CC0020|0x40000000)
DllCall("ReleaseDC", Ptr,win, Ptr,hDC)
if (id:=this.BindWindow(0,0,1))
WinGet, id, ID, ahk_id %id%
if (id)
{
WinGetPos, wx, wy, ww, wh, ahk_id %id%
left:=x, right:=x+w-1, up:=y, down:=y+h-1
left:=left<wx ? wx:left, right:=right>wx+ww-1 ? wx+ww-1:right
up:=up<wy ? wy:up, down:=down>wy+wh-1 ? wy+wh-1:down
x:=left, y:=up, w:=right-left+1, h:=down-up+1
}
if (id) and !(w<1 or h<1)
{
hDC2:=DllCall("GetDCEx", Ptr,id, Ptr,0, "int",3, Ptr)
DllCall("BitBlt",Ptr,mDC,"int",x-zx,"int",y-zy,"int",w,"int",h
, Ptr,hDC2, "int",x-wx, "int",y-wy, "uint",0x00CC0020|0x40000000)
DllCall("ReleaseDC", Ptr,id, Ptr,hDC2)
}
DllCall("SelectObject", Ptr,mDC, Ptr,oBM)
DllCall("DeleteDC", Ptr,mDC)
}
*/
;-----------------
if FileExist(file:="C:\Users\User\Documents\x.png")
{
pBitmap := Gdip_CreateBitmapFromFile(file)
w:=Gdip_GetImageWidth(pBitmap), h:=Gdip_GetImageHeight(pBitmap)
w:=w>zw ? zw:w, h:=h>zh ? zh:h
hBM2:=Gdip_CreateHBITMAPFromBitmap(pBitmap), Gdip_DisposeImage(pBitmap)
mDC:=DllCall("CreateCompatibleDC", Ptr,0, Ptr)
oBM:=DllCall("SelectObject", Ptr,mDC, Ptr,hBM, Ptr)
mDC2:=DllCall("CreateCompatibleDC", Ptr,0, Ptr)
oBM2:=DllCall("SelectObject", Ptr,mDC2, Ptr,hBM2, Ptr)
DllCall("BitBlt",Ptr,mDC,"int",0,"int",0,"int",w,"int",h
, Ptr,mDC2, "int",0, "int",0, "uint",0x00CC0020|0x40000000)
DllCall("SelectObject", Ptr,mDC2, Ptr,oBM2)
DllCall("DeleteDC", Ptr,mDC2)
DllCall("SelectObject", Ptr,mDC, Ptr,oBM)
DllCall("DeleteDC", Ptr,mDC)
DllCall("DeleteObject", Ptr,hBM2)
}
;-----------------