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);
            }
      
        }
    }
    

      

  • 相关阅读:
    Css进阶
    Css布局
    遇到的小问题
    MySQL 8.017连接Navicat中出现的问题
    ConcurrentHashMap图文源码解析
    HashMap图文源码解析
    接口和抽象类
    dependencies 和 devDependencies
    2020.7.7第二天
    2020.7.6第一天
  • 原文地址:https://www.cnblogs.com/songxingzhu/p/3024646.html
Copyright © 2011-2022 走看看