zoukankan      html  css  js  c++  java
  • 调用WindowApi来控制鼠标

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Runtime.InteropServices;
    using System.Text;
    
    namespace ISMS.WinServer.Utility
    {
        /// <summary>
        /// 
        /// </summary>
        public class MouseApi
        {
            [DllImport("User32.dll")]
            static extern void mouse_event(MouseEventFlag flags, int dx, int dy, uint data, UIntPtr extraInfo);
            [Flags]
            enum MouseEventFlag : uint
            {
                Move = 0x001, LeftDown = 0x0002, LeftUP = 0x0004, RightDown = 0x0008,
                RightUp = 0x0010, MiddleDown = 0x0020, MiddleUP = 0x0040, Absolut = 0x8000, xDown = 0x0080, xUp = 0x0100, wheel = 0x0800, virtualDesk = 0x4000
            }
            public void LeftClick()
            {
                mouse_event(MouseEventFlag.LeftUP, 0, 0, 0, UIntPtr.Zero);
                mouse_event(MouseEventFlag.LeftDown, 0, 0, 0, UIntPtr.Zero);
                mouse_event(MouseEventFlag.LeftUP, 0, 0, 0, UIntPtr.Zero);
            }
            public void RightClick()
            {
                mouse_event(MouseEventFlag.RightUp, 0, 0, 0, UIntPtr.Zero);
                mouse_event(MouseEventFlag.RightDown, 0, 0, 0, UIntPtr.Zero);
                mouse_event(MouseEventFlag.RightUp, 0, 0, 0, UIntPtr.Zero);
            }
            public void MiddleClick()
            {
                mouse_event(MouseEventFlag.MiddleUP, 0, 0, 0, UIntPtr.Zero);
                mouse_event(MouseEventFlag.MiddleDown, 0, 0, 0, UIntPtr.Zero);
                mouse_event(MouseEventFlag.MiddleUP, 0, 0, 0, UIntPtr.Zero);
            }
      
        }
    }
    

      

  • 相关阅读:
    团队项目-需求分析报告
    团队项目-选题报告
    第一次结对编程作业
    第一次个人编程作业
    软件工程作业(一)
    期末总结
    第04组 Beta冲刺(2/5)
    第04组 Beta冲刺(3/5)
    第04组 Beta冲刺(4/5)
    第04组 Beta冲刺(5/5)
  • 原文地址:https://www.cnblogs.com/songxingzhu/p/3024646.html
Copyright © 2011-2022 走看看