My code:
#Warn All, off
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
CoordMode, Mouse, Screen
#Include gdip.ahk ; is in the post attachment if anyone needs
If (!pToken := Gdip_Startup()){
ExitApp
}
return
f1::
WinGet, id, ID, A
return
f2::
pBitmap := Gdip_BitmapFromHWND(id)
Gdip_SaveBitmapToFile(pBitmap, "screen.bmp", 100)
Gdip_DisposeImage(pBitmap)
return
f12::
exitapp
My result:
I'm testing it on Win10 x64 and being honest I'm out of ideas. Not sure if it returns blank window because of win10, graphic card, because of the target app itself... Have you got any tips for me? What can be wrong?
Thanks in advance
Gdip_BitmapFromHWND returns blank window
- Brazolek123
- Posts: 187
- Joined: 06 Jun 2016, 16:02
Gdip_BitmapFromHWND returns blank window
- Attachments
-
- gdip.ahk
- (128.62 KiB) Downloaded 54 times
Re: Gdip_BitmapFromHWND returns blank window
You want to make a screenshot from a window? You receive a hwnd to a window instead with Winget. There are much screenshot functions around in this forum. I'm not on my computer at moment, so I can't post one.
Re: Gdip_BitmapFromHWND returns blank window
Code: Select all
image := 0x187410 ; Some sort of hwnd.
image := WinExist(image) ? WinExist(image) : image
if DllCall("IsIconic", "ptr",image)
DllCall("ShowWindow", "ptr",image, "int",4) ; Restore if minimized!
VarSetCapacity(rc, 16)
DllCall("GetClientRect", "ptr",image, "ptr",&rc)
hbm := CreateDIBSection(NumGet(rc, 8, "int"), NumGet(rc, 12, "int"))
VarSetCapacity(rc, 0)
hdc := CreateCompatibleDC()
obm := SelectObject(hdc, hbm)
DllCall("PrintWindow", "ptr",image, "ptr",hdc, "uint",0x3)
pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
return pBitmap
Who is online
Users browsing this forum: Chunjee, mebelantikjaya, rc76 and 309 guests