Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

COPY to CLIPn:?

May
13,402
190
How does it work? What are the rules?

If I COPY a text file to CLIPn: it works. That is, the content of the file becomes the content of CLIPn:.

If I try to COPY something else (e.g., a JPG), it seems OK (though the target name is wrong in COPY's confirmation message).

Code:
v:\> copy callstack.jpg clip1:
V:\callstack.jpg => clip:      <==== target name?
     1 file copied

But there's not really a copy of the file in CLIP1:.

Code:
v:\> clip | head /n4
CLIP0: v:\> copy callstack.jpg clip1:
V:\callstack.jpg => clip:
     1 file copied
CLIP1: ÿØÿà

v:\> echo %@clip[0,1]
ÿØÿà

v:\> echo %@clip[1,1]
**EOC**

That is, in fact, the first 4 bytes of the file; the fifth byte of the file is 0.
 
And in a situation where you might expect a COPY to work well, there's an error.

Code:
v:\> echo This is a test. > clip:

v:\> type clip:
This is a test.

v:\> copy clip: clip6:
clip: => clip6:
TCC: (Sys) The filename, directory name, or volume label syntax is incorrect.
 "clip6:"
     0 files copied       1 failed
 
@Joe Caverly wrote a nifty tool to identify the clipboard contents a number of years ago. I have no idea how/if it works with the multiple clipboards.
Code:
::-------------------------------------------------------
:: CLIPFMT.BTM
:: Shows how many different formats are on the clipboard,
::  then lists the clipboard formats.
::
:: 2013/10/15
:: Joe Caverly
::
::TCC  15.01.52  Windows Vista [Version 6.0.6002]
::TCC Build 52  Windows Vista Build 6002  Service Pack 2
::--------------------------------------------------------
@setlocal
@echo off
set rc=%@winapi[user32.dll,OpenClipboard,0]
iff %rc gt 0 then
  echo Clipboard Open
  set ln=%@winapi[user32.dll,CountClipboardFormats]
  echo There are %ln clipboard formats.
  set uFormat=0
  do kount=1 to %ln
   set uFormat=%@winapi[user32.dll,EnumClipboardFormats,%uFormat]
   echos %@format[5,%uFormat] (0x%@format[04,%@convert[10,16,%uFormat]])` - `
   gosub ClipboardGetFormatName
  enddo
  set rc=%@winapi[user32.dll,CloseClipboard]
  if %rc gt 0 echo Clipboard Closed
else
  echo Could not open Clipboard
endiff
endlocal

quit

:ClipboardGetFormatName
switch %uFormat
case 1
  echo CF_TEXT
case 2
  echo CF_BITMAP
case 3
  echo CF_METAFILEPICT
case 4
  echo CF_SYLK
case 5
  echo CF_DIF
case 6
  echo CF_TIFF
case 7
  echo CF_OEMTEXT
case 8
  echo CF_DIB
case 9
  echo CF_PALETTE
case 10
  echo CF_PENDATA
case 11
  echo CF_RIFF
case 12
  echo CF_WAVE
case 13
  echo CF_UNICODETEXT
case 14
  echo CF_ENHMETAFILE
case 15
  echo CF_HDROP
case 16
  echo CF_LOCALE
case 17
  echo CF_DIBV5
case 18
  echo CF_MAX
case %@convert[16,10,0080]
  echo CF_OWNERDISPLAY
case %@convert[16,10,0081]
  echo CF_DSPTEXT
case %@convert[16,10,0082]
  echo CF_DSPBITMAP
case %@convert[16,10,0083]
  echo CF_DSPMETAFILEPICT
case %@convert[16,10,008E]
  echo CF_DSPENHMETAFILE
case %@convert[16,10,0200]
  echo CF_PRIVATEFIRST
case %@convert[16,10,02FF]
  echo CF_PRIVATELAST
case %@convert[16,10,0300]
  echo CF_GDIOBJFIRST
case %@convert[16,10,03FF]
  echo CF_GDIOBJLAST
case 49158
  echo FileName
case 49159
  echo FileNameW
case 49161
  echo DATAOBJECT
case 49171
  echo Ole Private Data
case 49380
  echo Shell Object Offsets
case 49382
  echo FileContents
case 49383
  echo FileGroupDescriptor
case 49389
  echo Preferred DropEffect
case 49268
  echo Shell IDList Array
case 49438
  echo CF_HTML
case 49619
  echo RenPrivateFileAttachments
default
  echo UNKNOWN
endswitch
return
 
For copying images to/from the clipboard, I have relied on NirCmd copyimage to do that task.

Example;
Code:
nircmd.exe clipboard copyimage 30Baseline.png
Usage:
1687369055282.png


I have an alias for clipboard;
Code:
clipboard=nircmd.exe clipboard %$

Joe
 
I agree with @rconn when he said;
For what you actually want (temporary files, not clipboards) it would make much more sense to add a new pseudo-device. Something like TMP0: - TMP9:

clip1: to clip9: are not actual clipboards, AFAIK.

You can't use the Windows API to work with clip1: to clip9:, only with clip:

We've become used to the clipboard being treated as a file, when it is not a file.

That is, it works great for text and TCC, but not so great for non-text.

My vote goes to TMP0: - TMP9:, that would allow the easy storage/retrieval of items beyond simple text.

Joe
 
TCC only supports text (ANSI and Unicode) in the clipboards. Always has.
Yes. After thinking about it that was clear. So what actually happens when I say COPY non_text_file CLIP:? Do I get the actual contents of the file up to the first NUL (or up to some point)?
 
Back
Top
[FOX] Ultimate Translator
Translate