C # read the next line from the clipboard and wrap the line in quotation marks?

I have a program that I am writing that looks like search and replace. I work in SQL and on a daily basis I copy the result of the data and need to search on 100 other accounts. I managed to add them to the clipboard and manipulate the clipboard to transfer to quotes. However, I am wondering if it is possible to read lines on the clipboard? The overall conclusion will be lower

This is the current output
"123456
123456
123456
123456
123456
123456"

The result should be "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();
        }
    }
}
+4
2

, :

  string result = string.Join("," + Environment.NewLine, Clipboard
    .GetText()
    .Split(new String[] { Environment.NewLine }, StringSplitOptions.None)
    .Select(line => "\"" + line + "\""));

  Clipboard.SetText(result);
+2
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);
}
0

Source: https://habr.com/ru/post/1668276/


All Articles