How can you get the clipboard contents with a Wind

2019-02-03 03:14发布

For example, I can copy a file to the clipboard like this:

clip < file.txt

(Now the contents of file.txt is in the clipboard.)

How can I do the opposite:

???? > file.txt

So that the contents of the clipboard will be in file.txt?

7条回答
我欲成王,谁敢阻挡
2楼-- · 2019-02-03 03:39

Here is the CLIP program by Dave Navarro, as referred to in the answer by @foxidrive. It is mentioned in an article here: copying-from-clipboard-to-xywrite

A link to the download, along with many other resources is on this page: http://www.lexitec.fi/xywrite/utility.html

Here is a direct link to the download: "DOWNLOAD Clip.exe Copy from and to the clipboard by Dave Navarro, Jr."

查看更多
我只想做你的唯一
3楼-- · 2019-02-03 03:47

If you accept to use PowerShell (and not cmd) the you can use Get-Clipboard exactly as you was looking for.

Get-Clipboard > myfile.txt

The adventage of this method is that you have nothing to install.

Note: In place of clip you can use Set-Clipboard that has more options.

Note 2: If you really want to run it from cmd, you can call powershell as in the following example powershell -command "Get-Clipboard | sort | Set-Clipboard".

查看更多
仙女界的扛把子
4楼-- · 2019-02-03 03:48

You can use the paste.exe software in order to paste text just like you are describing.

http://www.c3scripts.com/tutorials/msdos/paste.html

With it you can do:

paste | command

to paste the contents of the windows clipboard into the input of the specified command prompt

or

paste > filename

to paste the clipboard contents to the specified file.

查看更多
干净又极端
5楼-- · 2019-02-03 03:55

I have a pair of utilities (from before the Clip command was part of windows) available on this page:

http://www.clipboardextender.com/general-clipboard-use/command-window-output-to-clipboard-in-vista

There are two utilities in there, Clip2DOS and DOS2Clip. You want Clip2DOS:

Clip2DOS Copyright 2006 Thornsoft Development Dumps clipboard text (1024 bytes) to stdout.
Usage: Clip2Dos.exe > out.txt Result: text is in the file. Limits: 1024 bytes. License: Free, as in Free Beer! http://www.thornsoft.com/dist/techsupport/dos2clip.zip

DELPHI SOURCE INCLUDED!

And hey, here it is (Clip2DOS.dpr) :

{Clip2DOS - copyright 2005 Thornsoft Development, Inc.  All rights reserved.}
program Clip2Dos;

{$APPTYPE CONSOLE}

uses
  Clipbrd,
  ExceptionLog,
  SysUtils;

var
   p : Array[0..1024] of Char;
begin
  try
    WriteLn('Clip2DOS Copyright 2006 Thornsoft Development');
    Clipboard.GetTextBuf(p,1024);
    WriteLn(p);
  except
    //Handle error condition
    on E: Exception do
            begin
              beep;
              Writeln(SysUtils.format('Clip2DOS - Error: %s',[E.Message]));
              ExitCode := 1;    //Set ExitCode <> 0 to flag error condition (by convention)
            end;
  end
end.
查看更多
Bombasti
6楼-- · 2019-02-03 03:55

I know I'm really late to answer this, but you could write:

type file.txt | clip

So the content of the clipboard will be the content of file.txt

查看更多
淡お忘
7楼-- · 2019-02-03 03:57

There are third party clip commands that work bidirectionally.

Here's one:

    CLIP - Copy the specified text file to the clip board
    Copyright (c) 1998,99 by Dave Navarro, Jr. (dave@basicguru.com)
查看更多
登录 后发表回答