-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclipio.cs
More file actions
39 lines (37 loc) · 934 Bytes
/
clipio.cs
File metadata and controls
39 lines (37 loc) · 934 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.Text;
using System.Windows.Forms;
public class Program
{
[STAThread]
public static void Main(string[] args)
{
if (args.Length != 1) Usage();
if (string.Compare(args[0].ToLower(), "read") == 0)
{
Console.Write(Clipboard.GetText());
return;
}
if (string.Compare(args[0].ToLower(), "write") == 0)
{
var sb = new StringBuilder();
string line;
while (null != (line = Console.ReadLine()))
sb.AppendLine(line);
Clipboard.SetText(sb.ToString());
return;
}
Usage();
}
public static void Usage()
{
Console.Error.WriteLine("Requires one argument");
Console.Error.WriteLine();
Console.Error.WriteLine(" read");
Console.Error.WriteLine(" Print the contents of the clipboard to stdout");
Console.Error.WriteLine();
Console.Error.WriteLine(" write");
Console.Error.WriteLine(" Set the contents of the clipboard to stdin");
Environment.Exit(1);
}
}