返回提交历史
Modified
XFE各类拓展.NetCore.InputSimulator/InputSimulator.cs
+23
-1
XFEstudio/XFEExtension.NetCore.InputSimulator
添加鼠标模拟部分
19b4468
代码差异
1 个文件
+23
-1
@@ -1,16 +1,34 @@
1
using System.Runtime.InteropServices;
1
using System.Drawing;
2
using System.Runtime.InteropServices;
2
3
3
4
namespace XFE各类拓展.NetCore.InputSimulator;
4
5
6
public enum MouseButtons
7
{
8
Left,
9
Right,
10
Middle
11
}
12
5
13
public static class InputSimulator
6
14
{
7
15
#region DLL引用
8
16
[DllImport("user32.dll", SetLastError = true)]
9
17
public static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, IntPtr dwExtraInfo);
18
[DllImport("user32.dll")]
19
static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, IntPtr dwExtraInfo);
20
[DllImport("user32.dll")]
21
[return: MarshalAs(UnmanagedType.Bool)]
22
static extern bool SetCursorPos(int x, int y);
10
23
#endregion
11
24
#region 常量
12
25
private const int KEYEVENTF_KEYDOWN = 0x0000; // Key down flag
13
26
private const int KEYEVENTF_KEYUP = 0x0002; // Key up flag
27
private const uint MOUSEEVENTF_MOVE = 0x0001;
28
private const uint MOUSEEVENTF_LEFTDOWN = 0x0002;
29
private const uint MOUSEEVENTF_LEFTUP = 0x0004;
30
private const uint MOUSEEVENTF_RIGHTDOWN = 0x0008;
31
private const uint MOUSEEVENTF_RIGHTUP = 0x0010;
14
32
#endregion
15
33
public static void PressKey(char key)
16
34
{
@@ -27,4 +45,8 @@ public static class InputSimulator
27
45
keybd_event(keyCode, 0, KEYEVENTF_KEYUP, IntPtr.Zero);
28
46
}
29
47
}
48
static void MouseClick(MouseButtons button, int x, int y)
49
{
50
51
}
30
52
}