123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- using System;
- using System.Runtime.InteropServices;
- namespace GUI
- {
- public class Win32Api
- {
- public const int WM_KEYDOWN = 0x100;
- public const int WM_KEYUP = 0x101;
- public const int WM_SYSKEYDOWN = 0x104;
- public const int WM_SYSKEYUP = 0x105;
- public const int WH_KEYBOARD_LL = 13;
- public const int WH_MOUSE_LL = 14;
- public const int MOUSEEVENTF_LEFTDOWN = 0x0002;
- public const int MOUSEEVENTF_MOVE = 0x0001;
- public const int MOUSEEVENTF_LEFTUP = 0x0004;
- public const int MOUSEEVENTF_ABSOLUTE = 0x8000;
- public const int MOUSEEVENTF_RIGHTDOWN = 0x0008;
- public const int MOUSEEVENTF_RIGHTUP = 0x0010;
- public const int MOUSEEVENTF_MIDDLEDOWN = 0x0020;
- public const int MOUSEEVENTF_MIDDLEUP = 0x0040;
- [StructLayout(LayoutKind.Sequential)]
- public class KeyboardHookStruct
- {
- public int vkCode;
- public int scanCode;
- public int flags;
- public int time;
- public int dwExtraInfo;
- }
- [StructLayout(LayoutKind.Sequential)]
- public class POINT
- {
- public int x;
- public int y;
- }
- [StructLayout(LayoutKind.Sequential)]
- public class MouseHookStruct
- {
- public POINT pt;
- public int hwnd;
- public int wHitTestCode;
- public int dwExtraInfo;
- }
- public delegate int HookProc(int nCode, Int32 wParam, IntPtr lParam);
- [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
- public static extern int SetWindowsHookEx(int idHook, HookProc lpfn, IntPtr hInstance, int threadId);
- [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
- public static extern bool UnhookWindowsHookEx(int idHook);
- [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
- public static extern int CallNextHookEx(int idHook, int nCode, Int32 wParam, IntPtr lParam);
- [DllImport("user32")]
- public static extern int ToAscii(int uVirtKey, int uScanCode, byte[] lpbKeyState, byte[] lpwTransKey, int fuState);
- [DllImport("user32")]
- public static extern int GetKeyboardState(byte[] pbKeyState);
- [DllImport("kernel32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
- public static extern IntPtr GetModuleHandle(string lpModuleName);
- [DllImport("kernel32.dll")]
- public static extern void AllocConsole();
- [DllImport("user32")]
- public static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
- }
- }
|