Repository navigation
Expand file tree
/
Copy pathNativeMethods.cs
More file actions
62 lines (50 loc) · 1.6 KB
/
Copy pathNativeMethods.cs
File metadata and controls
62 lines (50 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System.Runtime.InteropServices;
namespace mouse_nudge;
[StructLayout(LayoutKind.Sequential)]
struct MouseInput
{
public int Dx;
public int Dy;
public uint MouseData;
public uint Flags;
public uint Time;
public nint ExtraInfo;
}
[StructLayout(LayoutKind.Sequential)]
struct Input
{
public uint Type;
public MouseInput Mouse;
}
[StructLayout(LayoutKind.Sequential)]
struct LastInputInfo
{
public uint Size;
public uint Time;
}
static class NativeMethods
{
public const uint InputMouse = 0;
public const uint MouseEventMove = 0x0001;
public const uint MouseEventAbsolute = 0x8000;
public const uint MouseEventVirtualDesk = 0x4000;
public const int SmXVirtualScreen = 76;
public const int SmYVirtualScreen = 77;
public const int SmCxVirtualScreen = 78;
public const int SmCyVirtualScreen = 79;
public const uint EsContinuous = 0x80000000;
public const uint EsSystemRequired = 0x00000001;
public const uint EsDisplayRequired = 0x00000002;
[DllImport("user32.dll", SetLastError = true)]
public static extern uint SendInput(uint inputCount, ref Input inputs, int size);
[DllImport("user32.dll")]
public static extern int GetSystemMetrics(int index);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetLastInputInfo(ref LastInputInfo info);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DestroyIcon(nint handle);
[DllImport("kernel32.dll")]
public static extern uint SetThreadExecutionState(uint flags);
}