ç§»å¨é¼ æ å°ä½ æ³è¦çä½ç½®ï¼ç¶åè¿è¡ç¹å»ï¼æäºæ¶åæ¯å¾æç¨ç
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
private void button1_Click(object sender, EventArgs e)
{
var x = int.Parse(textBox1.Text);
var y = int.Parse(textBox2.Text);
Cursor.Position = new Point(x, y);
}
private void button2_Click(object sender, EventArgs e)
{
var x = int.Parse(textBox1.Text);
var y = int.Parse(textBox2.Text);
Cursor.Position = new Point(x, y);
System.Threading.Thread.Sleep(100);
// 模æé¼ æ 左鮿ä¸
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
// 模æé¼ æ å·¦é®å¼¹èµ·
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
}
int MOUSEEVENTF_LEFTDOWN = 0x0002;
int MOUSEEVENTF_LEFTUP = 0x0004;
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);