admin管理员组

文章数量:1533872

2024年5月13日发(作者:)

c# 调用API控制鼠标移动单击双击以及滚轮的公共类

using System;

using ;

using pServices; using g;

using ;

namespace KeyboardHook

{

///

/// Mouse buttons that can be pressed

///

public enum MouseButton

{

Left = 0x2,

Right = 0x8,

Middle = 0x20

}

///

/// Operations that simulate mouse events

///

public static class MouseSimulator

{

#region Windows API Code

[DllImport("")]

static extern int ShowCursor(bool show);

[DllImport("User32")]

public extern static void SetCursorPos(int x, int y);

[DllImport("")]

static extern void mouse_event(int flags, int dX, int dY, int

buttons, int

extraInfo);

[DllImport("")]

static extern void PostMessage(IntPtr hWnd, int Msg, int wParam,

uint

lParam);

const int MOUSEEVENTF_MOVE = 0x1;

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_WHEEL = 0x800;

const int MOUSEEVENTF_ABSOLUTE = 0x8000;

const int WM_MOUSEMOVE = 0x200;

const int WM_LBUTTONDOWN = 0x201;

const int WM_RBUTTONDOWN = 0x204;

const int WM_MBUTTONDOWN = 0x207;

本文标签: 移动鼠标调用控制滚轮