AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

GDI help pasting window screenshot into GUI

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
ifckladyluck



Joined: 20 Jan 2009
Posts: 16

PostPosted: Wed Jan 21, 2009 2:13 pm    Post subject: GDI help pasting window screenshot into GUI Reply with quote

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)
Back to top
View user's profile Send private message
ifckladyluck



Joined: 20 Jan 2009
Posts: 16

PostPosted: Wed Jan 21, 2009 11:23 pm    Post subject: Reply with quote

figured this out.
this code actually works, but i just forgot to startup gdi via gdi_startup()
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group