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
protected static class GlobalScreen.NativeHookThread extends Thread
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
Fields Modifier and Type Field Description protected NativeHookExceptionexceptionException thrown by this thread.-
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
-
Constructor Summary
Constructors Constructor Description NativeHookThread()Default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddisable()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.NativeHookExceptiongetException()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 Detail
-
exception
protected NativeHookException exception
Exception thrown by this thread.
-
-
Method Detail
-
getException
public NativeHookException getException()
Get the exception associated with the current hook, or null of no exception was thrown.- Returns:
- the
NativeHookExceptionor null.
-
enable
protected void enable() throws NativeHookExceptionNative 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
public void disable() throws NativeHookExceptionNative 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
protected static void dispatchEvent(NativeInputEvent event)
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.
-
-