您可以使用 system.windows.forms 在 C# 中移动鼠标和编写键盘输入。例如,以下代码使用 system.windows.forms 中的基本方法来移动鼠标和编写键盘输入
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//Make sure to add these as references in your project ahead of time
using System.Drawing;
using System.Windows.Forms;
namespace ConsoleApplication14
{
class Program
{
static void Main(string[] args)
{
//The following code sets the cursor position to the point Xpos,Ypos
//on the screen
int Xpos = 0;
int Ypos = 0;
Cursor.Position = new Point(Xpos,Ypos);
//The following writes the string KeyData to keyboard input
string KeyData = "Hello World";
SendKeys.SendWait(KeyData);
}
}
}
您还需要 System.Drawing 来使用鼠标光标操作点,所以不要忘记它!
这是一个精彩的视频,包含有关鼠标和键盘移动的信息https://www.youtube.com/watch?v=48k9eyVsC-M
注意:据我所知,虽然这些方法非常适合移动鼠标,但它们不会导致鼠标点击,因此您需要在其他地方进行研究以获取该信息
祝你好运!