You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.
A small change I made to the code to nicely shutdown the DeviceHookThread
(With the current version it stays running even if you call unhook())
Maybe it helps someone :))
DeviceHookThreads add new private field:
// Native thread id private volatile int nativeThreadId;
A small change I made to the code to nicely shutdown the DeviceHookThread
(With the current version it stays running even if you call unhook())
Maybe it helps someone :))
DeviceHookThreads add new private field:
// Native thread id private volatile int nativeThreadId;
DeviceHookThreads add to run() method:
@Override public void run() { WinDef.HMODULE handle = Kernel32.INSTANCE.GetModuleHandle(null); this.hhk = User32.INSTANCE.SetWindowsHookEx(hookType, eventReceiver, handle, 0); nativeThreadId = Kernel32.INSTANCE.GetCurrentThreadId(); int result; while ((result = getMessage()) != 0) { if (result == -1) { onFail(); break; } else { dispatchEvent(); } } unhook(); }
DeviceHookThreads add new exit() method:
// Stops the thread and removes the hook public void exit() { User32.INSTANCE.PostThreadMessage(nativeThreadId, WinUser.WM_QUIT, null, null); }
DeviceHookManager change unhook() method:
public void unhook(H eventReceiver) { hooks.get(eventReceiver).exit(); }
All the best
Felix
The text was updated successfully, but these errors were encountered: