How to capture the contents of the clipboard using the command line?


  1. Posts : 7
    Windows 7 64bit Professional
       #1

    How to capture the contents of the clipboard using the command line?


    There are lots of sites discussing how to redirect the output of the command line to the clipboard but nothing covering the opposite. I want to capture a link address I have copied to my clipboard and send it to a command line program, as a variable, in a script. Clip.exe seems to be the only command to deal with the clipboard but it only works the opposite way.

    If comparing to Linux I'm looking for the command identical to "clipboard=$(xclip -out)"
      My Computer


  2. Posts : 19,383
    Windows 10 Pro x64 ; Xubuntu x64
       #2
      My Computer


  3. Posts : 5,092
    Windows 7 32 bit
       #3

    Also AutoHotkey has a built in clipboard variable named Clipboard.
    To assign clipboard text contents to a variable
    MyText := Clipboard

    see Clipboard in the help. I recommend AutoHotkey_L variant as it has object/true array support.
      My Computer


  4. Posts : 7
    Windows 7 64bit Professional
    Thread Starter
       #4

    Hm I'll see what I can do, thanks, although I was hoping for a native solution :/
      My Computer


  5. Posts : 5,092
    Windows 7 32 bit
       #5

    xenphor said:
    Hm I'll see what I can do, thanks, although I was hoping for a native solution :/
    I suppose you could consider VBScript more "native" than AutoIt or AHK. :) There's probably a way to do it with VBS I would think. I just don't use it often. But I'm sure you can find sites with VBS code snippets.

    edit: another alternative is PowerShell. But I use that even less. I'm not well versed in it.
      My Computer


  6. Posts : 7
    Windows 7 64bit Professional
    Thread Starter
       #6

    Unfortunately all I know how to do is combine a few command line programs together in a script.
      My Computer


  7. Posts : 5,092
    Windows 7 32 bit
       #7

    I would take a look on boards like softpedia.com and sourceforge.net for free command line clipboard stuff that's more versatile than the MS clip.exe. There's bound to be free ones around.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 17:49.
Find Us