日期:2009-12-24  浏览次数:20541 次

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)
        {

        }
        #region API
        [DllImport("user32.dll")]
        static extern void mouse_event(MouseEventFlag flags, int dx, int dy, uint data, UIntPtr extraInfo);
        [Flags]
        enum MouseEventFlag : uint
        {
            // dwFlags常数 意义
            Move = 0x0001,            //移动鼠标
            LeftDown = 0x0002,            //模拟鼠标左键按下
            LeftUp = 0x0004,            //模拟鼠标左键抬起
            RightDown = 0x0008,            //模拟鼠标右键按下
            RightUp = 0x0010,            //模拟鼠标右键抬起
            MiddleDown = 0x0020,            //模拟鼠标中键按下
            MiddleUp = 0x0040,            //模拟鼠标中键抬起
            XDown = 0x0080,            //标示是否采用绝对坐标
            XUp = 0x0100,            //
            Wheel = 0x0800,            //
            VirtualDesk = 0x4000,            //
            Absolute = 0x8000            //


        }
        #endregion

  &n