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 NativeHookException
exception
Exception 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 void
disable()
Native implementation to stop the input hook.protected static void
dispatchEvent(NativeInputEvent event)
Dispatches an event to the appropriate processor.protected void
enable()
Native implementation to start the input hook.NativeHookException
getException()
Get the exception associated with the current hook, or null of no exception was thrown.void
run()
-
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
NativeHookException
or null.
-
enable
protected void enable() throws NativeHookException
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
public void disable() throws NativeHookException
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
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
- theNativeInputEvent
sent to the registered event listeners.
-
-