|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- using System.Runtime.InteropServices;
-
- namespace Common.system
- {
- public class MouseEventCommon
- {
-
-
-
- [DllImport("user32")]
- private static extern int mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
-
-
-
-
-
-
- [DllImport("user32.dll")]
- public static extern int SetCursorPos(int x, int y);
-
-
-
-
-
-
-
-
- [DllImport("user32.dll", CharSet = CharSet.Auto)]
- public static extern bool GetCursorPos(out POINT pt);
-
-
-
-
-
-
-
- public static void MouseLefClickEvent(int dx, int dy, int data)
- {
- GetCursorPos(out POINT pointRecord);
- mouse_event((int)MouseEventFlag.MiddleDown, pointRecord.X, pointRecord.Y, data, 0);
- mouse_event((int)MouseEventFlag.MiddleUp, pointRecord.X, pointRecord.Y, data, 0);
- }
- public static void MouseText(int dx, int dy)
- {
- mouse_event((int)MouseEventFlag.LeftDown, dx, dy, 0, 0);
- mouse_event((int)MouseEventFlag.LeftUp, dx, dy, 0, 0);
- }
-
-
-
-
- public static void MouseMiddleClickEvent(int data)
- {
- GetCursorPos(out POINT pointRecord);
- mouse_event((int)MouseEventFlag.MiddleDown, pointRecord.X, pointRecord.Y, data, 0);
- mouse_event((int)MouseEventFlag.MiddleUp, pointRecord.X, pointRecord.Y, data, 0);
- }
-
- public struct POINT
- {
- public int X;
- public int Y;
- public POINT(int x, int y)
- {
- this.X = x;
- this.Y = y;
- }
-
- }
-
- enum MouseEventFlag : uint
- {
-
- Move = 0x0001,
-
- LeftDown = 0x0002,
-
- LeftUp = 0x0004,
-
- RightDown = 0x0008,
-
- RightUp = 0x0010,
-
- MiddleDown = 0x0020,
-
- MiddleUp = 0x0040,
- XDown = 0x0080,
- XUp = 0x0100,
- Wheel = 0x0800,
- VirtualDesk = 0x4000,
-
- Absolute = 0x8000
- }
- }
- }
|