You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 regels
2.5 KiB

  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace Gma.System.MouseKeyHook.WinApi
  4. {
  5. internal static class HotkeysNativeMethods
  6. {
  7. /// <summary>
  8. /// Defines a system-wide hot key.
  9. /// </summary>
  10. /// <param name="hwnd">
  11. /// A handle to the window that will receive WM_HOTKEY messages generated by the hot key. If this parameter is NULL,
  12. /// WM_HOTKEY messages are posted to the message queue of the calling thread and must be processed in the message loop.
  13. /// </param>
  14. /// <param name="id">
  15. /// The identifier of the hot key. If the hWnd parameter is NULL, then the hot key is associated with the current
  16. /// thread rather than with a particular window. If a hot key already exists with the same hWnd and id parameters, see
  17. /// Remarks for the action taken.
  18. /// </param>
  19. /// <param name="fsModifiers">
  20. /// The keys that must be pressed in combination with the key specified by the uVirtKey parameter in order to generate
  21. /// the WM_HOTKEY message. The fsModifiers parameter can be a combination of the following values.
  22. /// </param>
  23. /// <param name="vk">
  24. /// The virtual-key code of the hot key. See Virtual Key Codes.
  25. /// </param>
  26. /// <returns>
  27. /// If the function succeeds, the return value is nonzero.
  28. /// If the function fails, the return value is zero. To get extended error information, call GetLastError.
  29. /// </returns>
  30. [DllImport("user32.dll")]
  31. public static extern int RegisterHotKey(IntPtr hwnd, int id, int fsModifiers, int vk);
  32. /// <summary>
  33. /// Frees a hot key previously registered by the calling thread.
  34. /// </summary>
  35. /// <param name="hwnd">
  36. /// A handle to the window associated with the hot key to be freed. This parameter should be NULL if the hot key is not
  37. /// associated with a window.
  38. /// </param>
  39. /// <param name="id">
  40. /// The identifier of the hot key to be freed.
  41. /// </param>
  42. /// <returns>
  43. /// If the function succeeds, the return value is nonzero.
  44. /// If the function fails, the return value is zero. To get extended error information, call GetLastError.
  45. /// </returns>
  46. [DllImport("user32.dll")]
  47. public static extern bool UnregisterHotKey(IntPtr hwnd, int id);
  48. }
  49. }