zoukankan      html  css  js  c++  java
  • 【C#学习笔记】鼠标控制

    using System;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;
    
    namespace ConsoleApplication1
    {
        class Program
        {
            public struct POINT
            {
                public int x, y;
            }
    
            const int MOUSEEVENTF_LEFTDOWN = 0x2;
            const int MOUSEEVENTF_LEFTUP = 0x4;
            const int MOUSEEVENTF_RIGHTDOWN = 0x8;
            const int MOUSEEVENTF_RIGHTUP = 0x10;
            const int MOUSEEVENTF_MIDDLEDOWN = 0x20;
            const int MOUSEEVENTF_MIDDLEUP = 0x40;
            const int MOUSEEVENTF_MOVE = 0x1;
    
    
            [DllImport("user32.dll")]
            public static extern int GetCursorPos(ref POINT p);
    
            [DllImport("user32.dll")]
            public static extern int SetCursorPos(int x, int y);
    
            [DllImport("user32.dll")]
            public static extern int mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
    
            static void Main(string[] args)
            {
                POINT p=new POINT();
                GetCursorPos(ref p);
                Console.WriteLine(p.x + " " + p.y);
    
                SetCursorPos(0, 0);
                mouse_event(MOUSEEVENTF_RIGHTDOWN, p.x, p.y, 0, 0);
                mouse_event(MOUSEEVENTF_RIGHTUP, p.x, p.y, 0, 0);
    
                Console.Read();
            }
        }
    }
  • 相关阅读:
    Bellman算法
    Codeforces Round #378 (Div. 2) D
    运算符优先级
    Kruskal算法
    Java 大数运算
    无根树转有根树
    欧拉函数模板
    HDU 4135 Co-prime(容斥原理)
    快速求n的质因子(数论)
    Markdown中插入数学公式
  • 原文地址:https://www.cnblogs.com/tiandsp/p/7440449.html
Copyright © 2011-2022 走看看