Skip to content

Instantly share code, notes, and snippets.

@kusa-mochi
Last active July 4, 2020 07:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kusa-mochi/c537789048040eb24e6720f82369e9fb to your computer and use it in GitHub Desktop.
Save kusa-mochi/c537789048040eb24e6720f82369e9fb to your computer and use it in GitHub Desktop.
using (Process currentProcess = Process.GetCurrentProcess ())
using (ProcessModule currentModule = currentProcess.MainModule) {
// メソッドをマウスのイベントに紐づける。
_mouseHookId = NativeMethods.SetWindowsHookEx (
NativeMethods.HookType.WH_MOUSE_LL,
_mouseProc,
NativeMethods.GetModuleHandle (currentModule.ModuleName),
0
);
// メソッドをキーボードのイベントに紐づける。
_keyboardHookId = NativeMethods.SetWindowsHookEx (
(int)NativeMethods.HookType.WH_KEYBOARD_LL,
_keyboardProc,
NativeMethods.GetModuleHandle (currentModule.ModuleName),
0
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment