日期:2009-12-25  浏览次数:20555 次

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;//光标操作的命名空间

namespace _模拟鼠标动作
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        [DllImport("user32.dll", EntryPoint = "SetCursorPos")]   //调用 的API
            //这个函数有两个个参数,第一个参数是指定光标的新的X坐标;第二个参数是指定光标的新的Y坐标。例如:SetCursorPos(100, 100);

        private static extern int SetCursorPos(int x, int y);

        private void Form1_Load(object sender, EventArgs e)
        {
            //SetCursorPos方法
            SetCursorPos(200,200); //光标会自动XY 数据的
        
         }
   }
}