Sign in to follow this  
Followers 0
EarthQ

Trying to capture window to clipboard using _ClipBoard_SetData() and _ScreenCapture_CaptureWnd()

1 post in this topic

Hi folks,

I am trying to accomplish a very simple task, but it seems not to work no matter what I try.

I want to open a window, and capture it to the clipboard using _ClipBoard_SetData(), without dumping screen capture to a file first and without using Send("!{PRINTSCREEN}") method.

The script below seems to be working with bitmap data, but cannot manage to put it into the clipboard once captured.

Any hints?

Thanks!

Run("calc.exe")

; Wait and allow 2 more seconds for Aero animations
$handle = WinWait("Calculator")
Sleep(2000)

; Initialize GDI+ library
_GDIPlus_Startup()

; Capture 32 bit bitmap
$hBitmap = _ScreenCapture_CaptureWnd("", $handle)
$hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)

; This shows data info as {B96B3CAA-0728-11D3-9D7B-0000F81EF32E} GUID, MEMORYBMP
;~ $aRet = _GDIPlus_ImageGetRawFormat($hImage)
;~ MsgBox(0,"dbg",$aRet[0])
;~ MsgBox(0,"dbg",$aRet[1])

; Trying to put image in clipboard <- This is what seems to be failing ...
_ClipBoard_SetData($hImage,$CF_BITMAP)


; Clean up resources
_GDIPlus_ImageDispose($hImage)
_WinAPI_DeleteObject($hBitmap)
; Shut down GDI+ library
_GDIPlus_Shutdown()

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0