2using System.Runtime.InteropServices;
10 [DllImport(
"user32.dll")]
11 static extern IntPtr GetForegroundWindow();
13 [DllImport(
"user32.dll")]
14 private static extern IntPtr FindWindow(
string className,
string windowName);
16 [DllImport(
"user32.dll")]
17 public static extern bool ClientToScreen(IntPtr hWnd, ref System.Drawing.Point lpPoint);
20 internal enum MOUSEEVENTF : uint
25 MOVE_NOCOALESCE = 0x2000,
38 [StructLayout(LayoutKind.Sequential)]
50 public static implicit
operator System.Drawing.Point(
POINT p)
52 return new System.Drawing.Point(p.
X, p.
Y);
55 public static implicit
operator POINT(System.Drawing.Point p)
61 [DllImport(
"user32.dll", SetLastError =
true)]
62 [
return: MarshalAs(UnmanagedType.Bool)]
63 static extern bool GetCursorPos(out POINT lpPoint);
64 [DllImport(
"user32.dll")]
65 static extern void mouse_event(MOUSEEVENTF dwFlags,
int dx,
int dy, uint dwData,
73 GetForegroundWindow();
75 FindWindow(
"UnityWndClass",
"VR Skills Toolkit");
78 System.Drawing.Point point =
new System.Drawing.Point(0, 0);
82 Debug.LogError(
"ERROR: can't get window pos!");
86 mouse_event((MOUSEEVENTF)0x8001, (ushort.MaxValue / Display.main.systemWidth) * (point.X + x), (ushort.MaxValue / Display.main.systemHeight) * (point.Y + y), 0, 0);
91 mouse_event(MOUSEEVENTF.LEFTDOWN | MOUSEEVENTF.LEFTUP, 0, 0, 0, 0);
96 mouse_event(MOUSEEVENTF.LEFTDOWN, 0, 0, 0, 0);
100 mouse_event(MOUSEEVENTF.LEFTUP, 0, 0, 0, 0);
104 mouse_event(MOUSEEVENTF.WHEEL,0,0,value,0);
static bool ClientToScreen(IntPtr hWnd, ref System.Drawing.Point lpPoint)
static void Scroll(uint value)
static void MoveMouse(int x, int y)