namespace zeroflag.Windows { using System; using System.Drawing; using System.Runtime.InteropServices; using System.Windows.Forms; public static class WinAPI { public static IntPtr Build(int low, int high) { return (IntPtr) (((short) low) | (((short) high) << 0x10)); } public static zeroflag.Windows.MouseButtons ConvertMouseButtons(System.Windows.Forms.MouseButtons value) { zeroflag.Windows.MouseButtons button = zeroflag.Windows.MouseButtons.None; if ((value & System.Windows.Forms.MouseButtons.Left) != System.Windows.Forms.MouseButtons.None) { button |= zeroflag.Windows.MouseButtons.MK_LBUTTON; } if ((value & System.Windows.Forms.MouseButtons.Right) != System.Windows.Forms.MouseButtons.None) { button |= zeroflag.Windows.MouseButtons.MK_RBUTTON; } if ((value & System.Windows.Forms.MouseButtons.Middle) != System.Windows.Forms.MouseButtons.None) { button |= zeroflag.Windows.MouseButtons.MK_MBUTTON; } if ((value & System.Windows.Forms.MouseButtons.XButton1) != System.Windows.Forms.MouseButtons.None) { button |= zeroflag.Windows.MouseButtons.MK_XBUTTON1; } if ((value & System.Windows.Forms.MouseButtons.XButton2) != System.Windows.Forms.MouseButtons.None) { button |= zeroflag.Windows.MouseButtons.MK_XBUTTON2; } return button; } public static IntPtr ConvertMousePosition(Point location) { return Build(location.X, location.Y); } [DllImport("user32.dll")] public static extern bool GetClientRect(IntPtr hWnd, ref LPRECT lpRect); [DllImport("user32.dll")] public static extern ulong GetLastError(); [DllImport("user32.dll")] public static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint vk); [DllImport("user32.dll")] public static extern bool RegisterHotKey(IntPtr hWnd, int id, ModKeys fsModifiers, Keys vk); [DllImport("user32.dll")] public static extern uint SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam); [DllImport("user32.dll")] public static extern uint SendMessage(IntPtr hWnd, WindowsMessages msg, IntPtr wParam, IntPtr lParam); [DllImport("user32.dll")] public static extern bool UnregisterHotKey(IntPtr hWnd, int id); public static IntPtr NULL { get { return IntPtr.Zero; } } [StructLayout(LayoutKind.Sequential)] public struct LPRECT { public long left; public long top; public long right; public long bottom; } } }