com.jniwrapper.win32.hook
Class Hook

java.lang.Object
  extended by com.jniwrapper.win32.hook.Hook
Direct Known Subclasses:
CBTHook, LowLevelKeyboardHook, LowLevelMouseHook

public class Hook
extends java.lang.Object

This class enables to install various Windows hooks and retrieve information from them using HookEventListener.

All avaiable hooks are represented by the Hook.Descriptor class.


Nested Class Summary
static class Hook.Descriptor
          This class represents the enumeraton of available Windows hooks.
 
Field Summary
protected  java.util.List _listeners
           
static Hook CALLWNDPROC
          Hook described by Hook.Descriptor.CALLWNDPROC descriptor.
static Hook CALLWNDPROCRET
          Hook described by Hook.Descriptor.CALLWNDPROCRET descriptor.
static CBTHook CBT
          Hook described by Hook.Descriptor.CBT descriptor.
static Hook FOREGROUNDIDLE
          Hook described by Hook.Descriptor.FOREGROUNDIDLE descriptor.
static Hook GETMESSAGE
          Hook described by Hook.Descriptor.GETMESSAGE descriptor.
static Hook JOURNALRECORD
          Hook described by Hook.Descriptor.JOURNALRECORD descriptor.
static Hook KEYBOARD
          Hook described by Hook.Descriptor.KEYBOARD descriptor.
static Hook KEYBOARD_LL
          Hook described by Hook.Descriptor.KEYBOARD_LL descriptor.
static Hook MOUSE
          Hook described by Hook.Descriptor.MOUSE descriptor.
static Hook MOUSE_LL
          Hook described by Hook.Descriptor.MOUSE_LL descriptor.
static Hook SHELL
          Hook described by Hook.Descriptor.SHELL descriptor.
static Hook SYSMSGFILTER
          Hook described by Hook.Descriptor.SYSMSGFILTER descriptor.
 
Method Summary
 void addListener(HookEventListener listener)
          Adds a hook event listener.
 Hook.Descriptor getDescriptor()
          Returns the descriptor of this hook.
 EventsFilter getFilter()
          Returns a specified events filter of this hook.
 void install()
          Installs the hook.
 boolean isInstalled()
          Verifies if the hook is installed.
 boolean isSynchronous()
          Returns the mode of this hook.
protected  void notifyListeners(HookEventObject event)
          Notifies listeners about a hook event.
 void removeListener(HookEventListener listener)
          Removes a hook event listener.
 void setFilter(EventsFilter filter)
          Specifies events filter for this hook.
 void setSynchronous(boolean synchronous)
          This method allows to swith between synchronous/asynchronous modes of the hook.
Note: synchronous mode may significatly reduce the performance of the system, so use this mode carefully.
 void uninstall()
          Uninstalls the hook.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_listeners

protected final java.util.List _listeners

JOURNALRECORD

public static final Hook JOURNALRECORD
Hook described by Hook.Descriptor.JOURNALRECORD descriptor.


KEYBOARD

public static final Hook KEYBOARD
Hook described by Hook.Descriptor.KEYBOARD descriptor.


KEYBOARD_LL

public static final Hook KEYBOARD_LL
Hook described by Hook.Descriptor.KEYBOARD_LL descriptor.


GETMESSAGE

public static final Hook GETMESSAGE
Hook described by Hook.Descriptor.GETMESSAGE descriptor.


CALLWNDPROC

public static final Hook CALLWNDPROC
Hook described by Hook.Descriptor.CALLWNDPROC descriptor.


CBT

public static final CBTHook CBT
Hook described by Hook.Descriptor.CBT descriptor.


SYSMSGFILTER

public static final Hook SYSMSGFILTER
Hook described by Hook.Descriptor.SYSMSGFILTER descriptor.


MOUSE

public static final Hook MOUSE
Hook described by Hook.Descriptor.MOUSE descriptor.


MOUSE_LL

public static final Hook MOUSE_LL
Hook described by Hook.Descriptor.MOUSE_LL descriptor.


SHELL

public static final Hook SHELL
Hook described by Hook.Descriptor.SHELL descriptor.


FOREGROUNDIDLE

public static final Hook FOREGROUNDIDLE
Hook described by Hook.Descriptor.FOREGROUNDIDLE descriptor.


CALLWNDPROCRET

public static final Hook CALLWNDPROCRET
Hook described by Hook.Descriptor.CALLWNDPROCRET descriptor.

Method Detail

getDescriptor

public Hook.Descriptor getDescriptor()
Returns the descriptor of this hook.

Returns:
hook descriptor

isInstalled

public boolean isInstalled()
Verifies if the hook is installed.

Returns:
true if the hook is installed.

addListener

public void addListener(HookEventListener listener)
Adds a hook event listener.

Parameters:
listener - a hook event listener.

removeListener

public void removeListener(HookEventListener listener)
Removes a hook event listener.

Parameters:
listener - a hook event listener.

install

public void install()
Installs the hook.


uninstall

public void uninstall()
Uninstalls the hook.


notifyListeners

protected void notifyListeners(HookEventObject event)
Notifies listeners about a hook event.

Parameters:
event - event object

isSynchronous

public boolean isSynchronous()
Returns the mode of this hook.

Returns:
true if this hook works in synchronous mode; false - in asynchronous mode.

setSynchronous

public void setSynchronous(boolean synchronous)
This method allows to swith between synchronous/asynchronous modes of the hook.
Note: synchronous mode may significatly reduce the performance of the system, so use this mode carefully.

Parameters:
synchronous - specifies the mode of the hook; if true then hook works in synchronous mode; false otherwise.

setFilter

public void setFilter(EventsFilter filter)
Specifies events filter for this hook.

Parameters:
filter - events filter

getFilter

public EventsFilter getFilter()
Returns a specified events filter of this hook.

Returns:
events filter