| 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:
 
 |  [DllImport("user32.dll")]private static extern IntPtr SetWindowsHookEx(HookType code, HookProc func, IntPtr hInstance, int threadID);
 
 [DllImport("user32.dll")]
 private static extern int CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);
 
 private delegate int HookProc(int code, IntPtr wParam, IntPtr lParam);
 private HookProc myCallbackDelegate = null;
 
 public enum HookType : int
 {
 WH_JOURNALRECORD = 0,
 WH_JOURNALPLAYBACK = 1,
 WH_KEYBOARD = 2,
 WH_GETMESSAGE = 3,
 WH_CALLWNDPROC = 4,
 WH_CBT = 5,
 WH_SYSMSGFILTER = 6,
 WH_MOUSE = 7,
 WH_HARDWARE = 8,
 WH_DEBUG = 9,
 WH_SHELL = 10,
 WH_FOREGROUNDIDLE = 11,
 WH_CALLWNDPROCRET = 12,
 WH_KEYBOARD_LL = 13,
 WH_MOUSE_LL = 14
 }
 
 
 public Form1()
 {
 InitializeComponent();
 
 this.myCallbackDelegate = new HookProc(this.KeyPressed);
 
 SetWindowsHookEx(HookType.WH_KEYBOARD, this.myCallbackDelegate, IntPtr.Zero, AppDomain.GetCurrentThreadId());
 
 }
 
 
 
 private int KeyPressed(int code, IntPtr wParam, IntPtr lParam)
 {
 if (code < 0) return CallNextHookEx(IntPtr.Zero, code, wParam, lParam);
 int i = wParam.ToInt32();
 if (i >= 112 && i <= 123)
 {
 i -= 111;
 abspielen(i);
 }
 
 return CallNextHookEx(IntPtr.Zero, code, wParam, lParam);
 }
 |