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

xenphor

New member
Local time
7:39 PM
Messages
7
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 My Computer

At a glance

Windows 7 64bit Professionali5 3570k8 gbNvidia gtx 680
Computer type
PC/Desktop
Computer Manufacturer/Model Number
custom
OS
Windows 7 64bit Professional
CPU
i5 3570k
Motherboard
Asus p8z77 v lk
Memory
8 gb
Graphics Card(s)
Nvidia gtx 680
Hard Drives
2 SATA
Antivirus
Clamav
Browser
Firefox

My Computer My Computer

At a glance

Windows 10 Pro x64 ; Xubuntu x64Intel i7 860 @ 2.80 GHz O/C'ed to 4.0GHz16GB Corsair Vengance DDR3 @ 661 MHz Dual Cha...EVGA NVidia GTX 560 1024MB
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Golden Mk. I.4
OS
Windows 10 Pro x64 ; Xubuntu x64
CPU
Intel i7 860 @ 2.80 GHz O/C'ed to 4.0GHz
Motherboard
Gigabyte P55A-UD3R Rev.1. Award BIOS F13
Memory
16GB Corsair Vengance DDR3 @ 661 MHz Dual Channel (9-9-9-24)
Graphics Card(s)
EVGA NVidia GTX 560 1024MB
Sound Card
Realtek Integrated
Monitor(s) Displays
Dual Samsung SyncMaster 2494HS
Screen Resolution
1920*1080 and 1920*1080
Hard Drives
1*Samsung 840 EVO 120GB SSD;
1*OCZ Vertex 2 60GB SSD;
2*Samsung F3 SpinPoint 1TB in RAID0;
1*Samsung F1 SpinPoint 1TB;
2*Western Digital 1TB External USB 3.0
1*Western Digital 500GB External USB 3.0
1*Seagate 500GB External USB 2.0
PSU
Thermaltake ToughPower QFan 750W
Case
Thermaltake Element S VK60001W2Z
Cooling
Corsair H60 Water Cooling, 2*230mm and 2*80mm case fans
Keyboard
Logitech G110
Mouse
Logitech MX518
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 My Computer

At a glance

Windows 7 32 bitAMD 5200+ dual core2 GBNVidia GeForce 6150SE 128 MB
Computer Manufacturer/Model Number
HP Media Center
OS
Windows 7 32 bit
CPU
AMD 5200+ dual core
Memory
2 GB
Graphics Card(s)
NVidia GeForce 6150SE 128 MB
Monitor(s) Displays
CRT
Screen Resolution
1280x1024
Hard Drives
500 GB Sata internal :

SIIG USB 3.0 docking stations w/WD Caviar Black 6 Gb/s drives
Keyboard
PS/2
Mouse
PS/2 Wheel Mouse
Other Info
SIIG USB 3.0 PCIexpress card.
Hm I'll see what I can do, thanks, although I was hoping for a native solution :/
 

My Computer My Computer

At a glance

Windows 7 64bit Professionali5 3570k8 gbNvidia gtx 680
Computer type
PC/Desktop
Computer Manufacturer/Model Number
custom
OS
Windows 7 64bit Professional
CPU
i5 3570k
Motherboard
Asus p8z77 v lk
Memory
8 gb
Graphics Card(s)
Nvidia gtx 680
Hard Drives
2 SATA
Antivirus
Clamav
Browser
Firefox
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 My Computer

At a glance

Windows 7 32 bitAMD 5200+ dual core2 GBNVidia GeForce 6150SE 128 MB
Computer Manufacturer/Model Number
HP Media Center
OS
Windows 7 32 bit
CPU
AMD 5200+ dual core
Memory
2 GB
Graphics Card(s)
NVidia GeForce 6150SE 128 MB
Monitor(s) Displays
CRT
Screen Resolution
1280x1024
Hard Drives
500 GB Sata internal :

SIIG USB 3.0 docking stations w/WD Caviar Black 6 Gb/s drives
Keyboard
PS/2
Mouse
PS/2 Wheel Mouse
Other Info
SIIG USB 3.0 PCIexpress card.
Unfortunately all I know how to do is combine a few command line programs together in a script.
 

My Computer My Computer

At a glance

Windows 7 64bit Professionali5 3570k8 gbNvidia gtx 680
Computer type
PC/Desktop
Computer Manufacturer/Model Number
custom
OS
Windows 7 64bit Professional
CPU
i5 3570k
Motherboard
Asus p8z77 v lk
Memory
8 gb
Graphics Card(s)
Nvidia gtx 680
Hard Drives
2 SATA
Antivirus
Clamav
Browser
Firefox
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 My Computer

At a glance

Windows 7 32 bitAMD 5200+ dual core2 GBNVidia GeForce 6150SE 128 MB
Computer Manufacturer/Model Number
HP Media Center
OS
Windows 7 32 bit
CPU
AMD 5200+ dual core
Memory
2 GB
Graphics Card(s)
NVidia GeForce 6150SE 128 MB
Monitor(s) Displays
CRT
Screen Resolution
1280x1024
Hard Drives
500 GB Sata internal :

SIIG USB 3.0 docking stations w/WD Caviar Black 6 Gb/s drives
Keyboard
PS/2
Mouse
PS/2 Wheel Mouse
Other Info
SIIG USB 3.0 PCIexpress card.
Back
Top