Module com.github.kwhat.jnativehook
Package com.github.kwhat.jnativehook
Class GlobalScreen.NativeHookThread
java.lang.Object
java.lang.Thread
com.github.kwhat.jnativehook.GlobalScreen.NativeHookThread
- All Implemented Interfaces:
Runnable
- Enclosing class:
- GlobalScreen
Specialized thread implementation for the native hook.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsFields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddisable()Native implementation to stop the input hook.protected static voiddispatchEvent(NativeInputEvent event) Dispatches an event to the appropriate processor.protected voidenable()Native implementation to start the input hook.Get the exception associated with the current hook, or null of no exception was thrown.voidrun()Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
Field Details
-
exception
Exception thrown by this thread.
-
-
Constructor Details
-
NativeHookThread
public NativeHookThread()Default constructor.
-
-
Method Details
-
run
public void run() -
getException
Get the exception associated with the current hook, or null of no exception was thrown.- Returns:
- the
NativeHookExceptionor null.
-
enable
Native implementation to start the input hook. This method blocks and should only be called by this specialized thread implementation. This method will notifyAll() after passing any exception exception throwing code.- Throws:
NativeHookException- problem registering the native hook with the underlying operating system.
-
disable
Native implementation to stop the input hook. There is no other way to stop the hook.- Throws:
NativeHookException- problem un-registering the native hook with the underlying operating system.
-
dispatchEvent
Dispatches an event to the appropriate processor. This method is generally called by the native library but may be used to synthesize native events from Java without replaying them on the native system. If you would like to send events to other applications, please useGlobalScreen.postNativeEvent(com.github.kwhat.jnativehook.NativeInputEvent),Note: This method executes on the native system's event queue. It is imperative that all processing be off-loaded to other threads. Failure to do so might result in the delay of user input and the automatic removal of the native hook.
- Parameters:
event- theNativeInputEventsent to the registered event listeners.
-