Posts: 1,271
Threads: 399
Joined: Mar 2003
scenario:
copy an image to the clipboard and save it to a destination.
Quote:Clipboard format is numeric value. If you know it's name as string, use function RegisterClipboardFormat to get numeric value.
i don't understand this part.
Posts: 12,091
Threads: 142
Joined: Dec 2002
RegisterClipboardFormat isn't related to bitmap copying.
;copy bitmap and save to test.bmp
str s.expandpath("$desktop$\test.bmp")
s.getsel(0 CF_BITMAP)
5
;paste test.bmp
s.setsel(CF_BITMAP)
When format is CF_BITMAP, s itself contains only filename, but not bitmap data
Posts: 1,271
Threads: 399
Joined: Mar 2003
Gintaras Wrote:RegisterClipboardFormat isn't related to bitmap copying.
i guess i need that. sorry that i was unclear :oops:
i want to save image data from the clipboard to a file.
like copy a layer in photoshop and save it to a file.
Posts: 12,091
Threads: 142
Joined: Dec 2002
Usually, applications store data into the clipboard in several formats. Some of them (values < 512) are standard formats. An application also can use registered formats (>32K) and private formats (512 - 1K).
Copy something, and run following code. It shows what formats currently are in the clipboard. Those with strings are registered. You can then use RegisterClipboardFormat to get numeric value.
dll user32
,#OpenClipboard hWnd
,#CloseClipboard
,#CountClipboardFormats
,#EnumClipboardFormats wFormat
,#GetClipboardFormatName wFormat $lpString nMaxCount
ClearOutput
int i f
str s
OpenClipboard 0
for i 0 CountClipboardFormats
,f=EnumClipboardFormats(f)
,s.fix(GetClipboardFormatName(f s s.all(100)))
,out "%i %s" f s
CloseClipboard
I tried it with selected wordart object in MS Word doc. I discovered that one of formats is "GIF". Then I executed following code, and result was normal gif file.
str s.getsel(0 RegisterClipboardFormat("GIF"))
s.setfile("$desktop$\test.gif")
Posts: 1,769
Threads: 410
Joined: Feb 2003
im trying to save a screen print to a file but cant seem to get the format right. when i run the code above to see what the format is all i get is
any idea what i should put in the
str e.getsel(0 RegisterClipboardFormat("GIF"))
line?
TY
Posts: 12,091
Threads: 142
Joined: Dec 2002
These are predefined formats, and one of them is CF_BITMAP (2).
You can save only to a bmp file.
Also, there is a bug in current QM version: key (44), and similar, produces one or more additional keys that depend on following text. The ) should be followed by space, as in example.
key (44) ;
1
str s.expandpath("$desktop$\screen.bmp")
s.getclip(CF_BITMAP)
Posts: 1,769
Threads: 410
Joined: Feb 2003
Wow!!!!
That works great. THANKS!!!!