我有一个类似于查找和替换的程序。我正在使用SQL并且每天复制数据结果并需要在另外100个帐户上进行搜索。我已设法将它们添加到剪贴板并操纵剪贴板以包装引号。但是我想知道是否可以读取剪贴板中的行?一般输出如下
这是电流输出
“123456个
123456个
123456个
123456个
123456个
123456"
输出应为
“123456”,
“123456”,
“123456”,
“123456”,
“123456”,
“123456”
我到目前为止的代码是winform应用程序
using System;
using System.Windows.Forms;
namespace ARMGUID
{
public sealed class HotkeyWindow : NativeWindow, IDisposable
{
public HotkeyWindow()
{
CreateHandle(new CreateParams());
}
protected override void WndProc(ref Message m)
{
const int WM_HOTKEY = 0x0312;
if (m.Msg == WM_HOTKEY)
{
string ARMguid = Clipboard.GetText();
string s = "\"" + ARMguid+"\n" + "\"";
Clipboard.SetText(s);
}
base.WndProc(ref m);
}
public void Dispose()
{
DestroyHandle();
}
}
}
答案 0 :(得分:2)
您可以尝试拆分,包装和加入:
string result = string.Join("," + Environment.NewLine, Clipboard
.GetText()
.Split(new String[] { Environment.NewLine }, StringSplitOptions.None)
.Select(line => "\"" + line + "\""));
Clipboard.SetText(result);
答案 1 :(得分:0)
if (m.Msg == WM_HOTKEY)
{
string result = string.Empty;
string ARMguid = Clipboard.GetText();
string[] lines = ARMguid.Split('\n');
foreach(var line in lines)
result += "\"" + ARMguid + "\",\n";
Clipboard.SetText(result);
}