By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,986 Members | 1,568 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,986 IT Pros & Developers. It's quick & easy.

GetClipboardData(CF_BITMAP) unimplemented

P: n/a
Win32all folks:

I am attempting to use win32all to perform screen captures and save
the bitmap to a file. The call to GetClipboardData fails saying
GetClipboardData(CF_BITMAP) is unimplemented. Any ideas?

My code looks something like this:

win32api.keybd_event(VK_SNAPSHOT, 0x45, KEYEVENTF_EXTENDEDKEY | 0, 0)
win32clipboard.OpenClipboard()
format = win32clipboard.EnumClipboardFormats()
data = win32clipboard.GetClipboardData(format)
win32clipboard.CloseClipboard()
writeFile = open('outfile.bmp','w')
writeFile.write(data)
writeFile.close()
Jul 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi !
And the same for .SetClipboardData(
Please... Please ?

Thanks by advance.


Jul 18 '05 #2

P: n/a
It's just that nobody has written code yet to do anything with the returned
bitmap handle. However, you can still do screen captures without it.
The below code should also work with just about any window handle,
not just the desktop
Roger

import win32gui, win32ui, win32con
hwnd=win32gui.GetDesktopWindow()
l,t,r,b=win32gui.GetWindowRect(hwnd)
h=b-t
w=r-l
hDC = win32gui.GetWindowDC(hwnd)
myDC=win32ui.CreateDCFromHandle(hDC)
newDC=myDC.CreateCompatibleDC()

myBitMap = win32ui.CreateBitmap()
myBitMap.CreateCompatibleBitmap(myDC, w, h)

newDC.SelectObject(myBitMap)
newDC.BitBlt((0,0),(w, h) , myDC, (0,0), win32con.SRCCOPY)
myBitMap.Paint(newDC)
myBitMap.SaveBitmapFile(newDC,'c:\\tmp.bmp')

"Kyle Harrigan" <kw********@yahoo.com> wrote in message
news:90**************************@posting.google.c om...
Win32all folks:

I am attempting to use win32all to perform screen captures and save
the bitmap to a file. The call to GetClipboardData fails saying
GetClipboardData(CF_BITMAP) is unimplemented. Any ideas?

My code looks something like this:

win32api.keybd_event(VK_SNAPSHOT, 0x45, KEYEVENTF_EXTENDEDKEY | 0, 0)
win32clipboard.OpenClipboard()
format = win32clipboard.EnumClipboardFormats()
data = win32clipboard.GetClipboardData(format)
win32clipboard.CloseClipboard()
writeFile = open('outfile.bmp','w')
writeFile.write(data)
writeFile.close()

Jul 18 '05 #3

P: n/a
Hi !

For screen-capture, with PIL, you can do too :

import Image, ImageGrab
ImageGrab.grab().save(filename)

But the question talk of CLIPBOARD and bitmap.

@+
--
Michel Claveau

Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.