简体   繁体   中英

C# I want to make a program can copy a text from my pc to a Virtual machine

What I have been trying to make is a program that takes a text input and then rewrites what is written, with a 3 second delay.

I have successfully made this program, so that it works on my own machine, but I want it to work, so that I can input text in it, and then target a notepad on a virtual machine. Is this possible?

What I have tried so far is:

private void button1_Click(object sender, EventArgs e)
{
    try
    {
        int time = int.Parse(textBox2.Text);
        Thread.Sleep(time * 1000);
        SendKeys.Send((textBox1.Text));
    }
    catch
    {

        MessageBox.Show("Input text / time");
    }
}

This is in a Windows Forms App .Net Framework 4.6.2

What you could do, is you could have one program that runs on your VM, and one program that runs on your local machine that communicate over a virtual network.

The program on your local machine can send a request to the program on the VM, and upon receiving that request, the program on the VM, can run the same SendKeys functions that your existing program uses.

When I communicate over a network, I usually use ASP.NET Web API . The tutorials on that should give you the knowledge to allow you to create a simple app that communicates over a network.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM