设置鼠标的位置

时间:2015-08-01 09:19:32

标签: c# position cursor

我无法解决我的错误:/

if (Cursor.Position = new Point(x, y)

我在x,y上出错,我想更改为50,99例如

1 个答案:

答案 0 :(得分:0)

首先你应该触发mouseClick事件。这很简单:

this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseClick);

然后你应该处理这个事件。假设您想要的位置是(x,y)=(100,100):

private void Form1_MouseClick(object sender, MouseEventArgs e)
    {
        int xDesired = 100;
        int yDesired = 100;
        if (e.X == xDesired && e.Y == yDesired)
            MessageBox.Show("Certain point clicked.");
    }