Sending data to a notepad using processes

后端 未结 5 1174
余生分开走
余生分开走 2021-01-23 21:11

I want to send every item from my listbox to a notepad,but my logic is kinda beating me.

private void send_Click(object sender, EventArgs e)
{
    var notepad =          


        
5条回答
  •  后悔当初
    2021-01-23 22:03

    I have a sample test, it works if you change SendKeys.Send to SendKeys.SendWait

        List data = new List() { "Test", "hope", "It", "works","Or" };
        foreach (var item in data)
        {
            Clipboard.Clear();
            Clipboard.SetText(item);
            //SendKeys.Send("^V");
            //SendKeys.Send("{ENTER}");
    
            SendKeys.SendWait("^V");
            SendKeys.SendWait("{ENTER}");
        }
    

    Because the key applied later than update Clipboard and loop, so that issue happend.

提交回复
热议问题