Posts: 858
Threads: 196
Joined: Apr 2005
I'm trying to perform actions depending on the contents of the clipboard into a graphic application (MicroStation).
Is it possible to identify the contents of the clipboard?
Posts: 12,095
Threads: 142
Joined: Dec 2002
Macro
Enum clipboard formats
;When you copy something in an application, it usually stores data in clipboard in several formats.
;This macro shows what formats are currently in the clipboard.
out
int f; str s
OpenClipboard 0
rep CountClipboardFormats
,f=EnumClipboardFormats(f)
,s.fix(GetClipboardFormatName(f s s.all(100)))
,out "%i %s" f s
CloseClipboard
out "<>The numbers without names are <link ''http://www.google.com/search?q=site:microsoft.com Clipboard Formats''>standard clipboard formats</link>."
Posts: 858
Threads: 196
Joined: Apr 2005
Is possible to get the contents of the clipboard in hex format and the size of data?
Posts: 12,095
Threads: 142
Joined: Dec 2002
What clipboard format? For each clipboard format, data format and storage is different.
Posts: 858
Threads: 196
Joined: Apr 2005
'MicroStation format' if is possible...
else Paint.
Posts: 12,095
Threads: 142
Joined: Dec 2002
Try this.
Macro
Macro1572
str s.getclip("MicroStation format")
out s.len
outb s iif(s.len<1000 s.len 1000) 1
Posts: 858
Threads: 196
Joined: Apr 2005
Posts: 858
Threads: 196
Joined: Apr 2005
When I copy one element in Microstation:
macro result:
14
49777 MicroStation Element
3
----------------------------
If I try
str s.getclip("MicroStation Element") ----> s.len=0
str s.getclip(14) -----> s.len=0
str s.getclip(3) ------> s.len=16 and s changes every time with the same object.
Other idea?
Posts: 12,095
Threads: 142
Joined: Dec 2002
getclip supports only clipboard formats where data is stored in global memory. Also bitmap.
We don't know where is stored data of "MicroStation Element" format, and how to get it.
Formats 3 and 14 are or contain metafile handles. Metafiles store pictures. To read more, click the link in QM output when you run macro "enum clipboard formats".
It is possible to get metafile data from handle. I never tried it. I would try GetEnhMetaFileBits or similar function, look in MSDN. Or maybe easier would be to save it to file with CopyEnhMetaFile, then getfile. To get handle, use format 14, but instead of getclip use OpenClipboard, GetClipboardData, CloseClipboard.
Posts: 858
Threads: 196
Joined: Apr 2005
I tried several methods but don't work (the object can be rotated or different size ...).
Now, the only thing that interests me is the name of the selected object. Do you know any method?
Posts: 12,095
Threads: 142
Joined: Dec 2002
No, I don't know where name is stored. Try to save with CopyEnhMetaFile, then look for name in the file.
From MSDN, "Enhanced Metafile Records".
Quote:An optional text description can follow the header record. The text description describes the picture and the author's name.
Posts: 858
Threads: 196
Joined: Apr 2005
Macro
Macro5
OpenClipboard 0
int h=GetClipboardData(14)
str f="$Desktop$\test\test11f"
f.expandpath
CopyEnhMetaFile h f
CloseClipboard
result:
test11e.zip (Size: 2.46 KB / Downloads: 320)
Do you know how decrypt the file?
Posts: 12,095
Threads: 142
Joined: Dec 2002
Macro
Macro1571
str s.getfile( "$desktop$\test11e.wmf")
outb s s.len 1
Contains text "MicroStation View" "View".
Posts: 858
Threads: 196
Joined: Apr 2005
but the search text should be: I811
Posts: 12,095
Threads: 142
Joined: Dec 2002
It is not in metafile. Probably it is in the microstation format, but we don't know about it.