Copy/paste command-line utilities
February 4, 2005 on 4:14 pm | In General |The use of the mouse pointer to mark and copy text from the Command window in Windows can be quite cumbersome. Out of exasperation, I created the following utilities that are based on _pbcopy_ and _pbpaste_, available in Mac OS X.
These require the .NET framework as can be seen below. The code compiled with Microsoft .NET Framework 1.1.
*clipin.cs*
using System;
using System.IO;
using System.Windows.Forms;
public class ClipboardCopy
{
public static void Main(string[] args)
{
string input = Console.In.ReadToEnd();
Clipboard.SetDataObject(input, true);
Console.WriteLine("Text copied to clipboard.");
}
}
*clipout.cs*
using System;
using System.IO;
using System.Windows.Forms;
public class ClipboardPaste
{
public static void Main(string[] args)
{
IDataObject data = Clipboard.GetDataObject();
if (data.GetDataPresent(DataFormats.Text) )
{
Console.Out.WriteLine("n" + data.GetData(DataFormats.Text)) ;
}
}
}
Usage: C: | clipin.exe
Usage: C:clipout.exe |
The code is pretty much self-explanatory and should not require further details. But if you need more information, please let me know.
Related Posts:
- How to Parse Dates from Strings
- Capturing keystrokes with GetAsyncKeyState
- How to Format Dates for SQL in Java
- Validating a Date Field with RIFE
No Comments yet »
RSS feed for comments on this post. TrackBack URI
Leave a comment
Powered by blog.mu with Pool theme design by Borja Fernandez.

