C#从windows剪贴板获取并显示文本内容
2018-07-20 来源:open-open
using System;
using System.Windows.Forms;
namespace RobvanderWoude
{
class Paste
{
[STAThread]
static int Main( string[] args )
{
if ( args.Length == 0 )
{
try
{
if ( Clipboard.ContainsText( ) )
{
string clipText = Clipboard.GetText( );
Console.Write( clipText );
return 0;
}
else
{
return 1;
}
}
catch ( Exception e )
{
Console.Error.WriteLine( e.Message );
return 2;
}
}
else
{
Console.Error.WriteLine( );
Console.Error.WriteLine( "Paste.exe, Version 1.01" );
Console.Error.WriteLine( "Read and display text from the clipboard" );
Console.Error.WriteLine( );
Console.Error.WriteLine( "Usage: PASTE" );
Console.Error.WriteLine( );
Console.Error.WriteLine( "Note: The program returns the following 'errorlevels':" );
Console.Error.WriteLine( " 0 success" );
Console.Error.WriteLine( " 1 no text available in clipboard" );
Console.Error.WriteLine( " 2 command line or unknown error" );
Console.Error.WriteLine( );
Console.Error.WriteLine( "Written by Rob van der Woude" );
Console.Error.WriteLine( "http://www.robvanderwoude.com" );
return 2;
}
}
}
}
标签: isp
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。
上一篇:C# 堆排序示例代码
下一篇:C#编写的屏幕监控代码
最新资讯
热门推荐