By Mitch Stuart
Copyright © 2003-2004 FullSpan Software
-
Usage subject to license
Software Version: 1.4
-
Document Version: $Revision: 1.2 $, $Date: 2004/01/05 03:30:55 $
2.1. Send To Clipboard (as name)
Beginning with Windows 95, Microsoft has made available an unsupported set of utilities called the PowerToys. There are several versions of the PowerToys available (this may not be a complete list):
However, for some reason, the Send To Clipboard (as name) PowerToy is not included in the most recent versions of the PowerToys, such as the Windows XP version. So I wrote ToClip to replace it.
Getting ToClip
toclip -a [-u] arg1 [...argN]
to place the command line argument(s) on the clipboard. If there is more than one argument, they will be separated by line breaks. Use the -u option to expand mapped drive letters to UNC paths.
to place the contents of standard input on the clipboard. The -u option is not supported in this mode. The contents of stdin must be text data (not binary).
From the Send To menu, you can also select Clipboard (as UNC name) to expand mapped drive letters. Universal Naming Convention (UNC) names are a standardized way to refer to a resource located on a Windows network. For example, let's say you have the network share \\accounting\reports mapped to your local computer as K:, and you are browsing the K:\current directory in Windows Explorer.
If you select Send To Clipboard (as name) for the file summary.xls, the text K:\current\summary.xls will be placed on the clipboard. But if you select Send To Clipboard (as UNC name), the text \\accounting\reports\current\summary.xls will be placed on the clipboard. This is convenient when documenting or emailing network links, because other users may have the network share mapped with a different drive letter (or not mapped at all). With a UNC name, the location of the file will be clear regardless of their local mappings.
You can select multiple files or directories (using the standard Ctrl-click or Shift-click mouse actions), and send all of the names to the clipboard. When you paste the result, each name will be on a separate line.
dir | toclip
will put the directory listing on the clipboard. And:
toclip <somefile.txt
will copy the contents of somefile.txt onto the clipboard.
ToClip only handles text data - it does not handle binary data (such as images).
Finally, you can tell ToClip to directly send the command-line arguments to the clipboard. This is how the Send To Clipboard (as name) feature works, except in this case you are directly typing the arguments instead of right-clicking the filename(s). For example:
toclip -a Hello World
will put this text on the clipboard:
Hello
World
And:
toclip -a "Hello World"
will put this text on the clipboard:
Hello World
C:\bin\toclip.exe -a
and for the name, enter:
Clipboard (as name)
or another name of your choice. (This is the name that will be displayed in the Send To menu.)
C:\bin\toclip.exe -a -u
and for the name, enter:
Clipboard (as UNC name)
or another name of your choice. (This is the name that will be displayed in the Send To menu.)
ToClip is written in C. I built toclip.exe in the Cygwin development environment, using the gcc compiler, and the MinGW windows libraries, all of which are easily downloaded and installed by the Cygwin installer. However, ToClip is a generic program; you should be able to compile it with any Windows C compiler/environment (although I haven't tested any others). To build ToClip in the Cygwin environment, use the build.sh file included with the distribution.
ToClip limits the size of the data placed on the clipboard to no more than 64,000 characters.
ToClip uses the Windows API function WNetGetUniversalName to expand mapped drive letters to their UNC paths.