Class GlobalScreen.NativeHookThread

  • All Implemented Interfaces:
    Runnable
    Enclosing class:
    GlobalScreen

    protected static class GlobalScreen.NativeHookThread
    extends Thread
    Specialized thread implementation for the native hook.
    • Constructor Detail

      • NativeHookThread

        public NativeHookThread()
        Default constructor.
    • Method Detail

      • run

        public void run()
        Specified by:
        run in interface Runnable
        Overrides:
        run in class Thread
      • 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 use GlobalScreen.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 - the NativeInputEvent sent to the registered event listeners.