|
I am trying to grab a window screenshot and paste it into a GUI picture control. This is the code im using below. Could someone tell me what I am doing wrong?
#Include, Gdip.ahk
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
Gui, +AlwaysOnTop -Disabled -SysMenu +Owner ; +Owner avoids a taskbar button.
Gui, Show, w640 h480 NoActivate, GuiWindow ; NoActivate avoids deactivating the currently active window.
Gui, Add, Picture, w640 h480 0xE vBackdrop
guicontrolGet, hCnt, hwnd, Backdrop
hBM := CreateDIBSection(Width, Height)
hDC := CreateCompatibleDC()
oBM := SelectObject(hdc, hbm)
dllcall("PrintWindow", "Uint", winexist("Semele"), "Uint", hDC)
pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
SetImage(hCnt, hBM)
|