Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
getclip (images)
#1
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.
pi
#2
RegisterClipboardFormat isn't related to bitmap copying.

Code:
;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
#3
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.

Code:
s.getclip(CF_BITMAP)
pi
#4
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.

Code:
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.

Code:
str s.getsel(0 RegisterClipboardFormat("GIF"))
s.setfile("$desktop$\test.gif")
#5
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
Code:
2
8
17
any idea what i should put in the
Code:
str e.getsel(0 RegisterClipboardFormat("GIF"))
line?

TY
#6
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.

Code:
key (44) ;
1
str s.expandpath("$desktop$\screen.bmp")
s.getclip(CF_BITMAP)
#7
Wow!!!!
That works great. THANKS!!!! Big Grin


Forum Jump:


Users browsing this thread: 1 Guest(s)