Class GlobalHookBase
- Namespace
- SharpHook
- Assembly
- SharpHook.dll
Represents an abstract implementation of IGlobalHook which defines everything needed except for a strategy for dispatching events and uses a global hook provider (libuiohook by default).
public abstract class GlobalHookBase : BasicGlobalHookBase, IGlobalHook, IBasicGlobalHook, IDisposable
- Inheritance
-
GlobalHookBase
- Implements
- Derived
- Inherited Members
Constructors
GlobalHookBase(GlobalHookType, IGlobalHookProvider?, bool)
Initializes a new instance of GlobalHookBase.
protected GlobalHookBase(GlobalHookType globalHookType = GlobalHookType.All, IGlobalHookProvider? globalHookProvider = null, bool runAsyncOnBackgroundThread = false)
Parameters
globalHookTypeGlobalHookTypeThe global hook type.
globalHookProviderIGlobalHookProviderThe underlying global hook provider, or null to use the default one.
runAsyncOnBackgroundThreadbooltrue if RunAsync() should run the hook on a background thread. Otherwise, false.
Methods
DispatchEvent(ref UioHookEvent)
Dispatches an event from libuiohook, i.e. raises the appropriate event.
protected void DispatchEvent(ref UioHookEvent e)
Parameters
eUioHookEventThe event to dispatch.
HandleHookEvent(ref UioHookEvent)
When implemented in a derived class, represents a strategy for handling a hook event.
protected override abstract void HandleHookEvent(ref UioHookEvent e)
Parameters
eUioHookEventThe event to handle.
Remarks
Derived classes should call DispatchEvent(ref UioHookEvent) inside this method to raise the appropriate event. They can also call ShouldDispatchEvent(ref UioHookEvent) to determine whether to attempt dispatching the event at all.
OnHookDisabled(HookEventArgs)
Raises the HookDisabled event with this object as the sender.
protected virtual void OnHookDisabled(HookEventArgs args)
Parameters
argsHookEventArgsThe arguments of the event.
OnHookEnabled(HookEventArgs)
Raises the HookEnabled event with this object as the sender.
protected virtual void OnHookEnabled(HookEventArgs args)
Parameters
argsHookEventArgsThe arguments of the event.
OnKeyPressed(KeyboardHookEventArgs)
Raises the KeyPressed event with this object as the sender.
protected virtual void OnKeyPressed(KeyboardHookEventArgs args)
Parameters
argsKeyboardHookEventArgsThe arguments of the event.
OnKeyReleased(KeyboardHookEventArgs)
Raises the KeyReleased event with this object as the sender.
protected virtual void OnKeyReleased(KeyboardHookEventArgs args)
Parameters
argsKeyboardHookEventArgsThe arguments of the event.
OnKeyTyped(KeyboardHookEventArgs)
Raises the KeyTyped event with this object as the sender.
protected virtual void OnKeyTyped(KeyboardHookEventArgs args)
Parameters
argsKeyboardHookEventArgsThe arguments of the event.
OnMouseClicked(MouseHookEventArgs)
Raises the MouseClicked event with this object as the sender.
protected virtual void OnMouseClicked(MouseHookEventArgs args)
Parameters
argsMouseHookEventArgsThe arguments of the event.
OnMouseDragged(MouseHookEventArgs)
Raises the MouseDragged event with this object as the sender.
protected virtual void OnMouseDragged(MouseHookEventArgs args)
Parameters
argsMouseHookEventArgsThe arguments of the event.
OnMouseMoved(MouseHookEventArgs)
Raises the MouseMoved event with this object as the sender.
protected virtual void OnMouseMoved(MouseHookEventArgs args)
Parameters
argsMouseHookEventArgsThe arguments of the event.
OnMousePressed(MouseHookEventArgs)
Raises the MousePressed event with this object as the sender.
protected virtual void OnMousePressed(MouseHookEventArgs args)
Parameters
argsMouseHookEventArgsThe arguments of the event.
OnMouseReleased(MouseHookEventArgs)
Raises the MouseReleased event with this object as the sender.
protected virtual void OnMouseReleased(MouseHookEventArgs args)
Parameters
argsMouseHookEventArgsThe arguments of the event.
OnMouseWheel(MouseWheelHookEventArgs)
Raises the MouseWheel event with this object as the sender.
protected virtual void OnMouseWheel(MouseWheelHookEventArgs args)
Parameters
argsMouseWheelHookEventArgsThe arguments of the event.
ShouldDispatchEvent(ref UioHookEvent)
Returns a value which indicates whether there are any subscribers to an event which corresponds to the hook event type.
protected bool ShouldDispatchEvent(ref UioHookEvent e)
Parameters
eUioHookEventThe event to check.
Returns
- bool
true if there are any subscribers to an event which corresponds to the hook event type. Otherwise, false.
Remarks
Derived classes may call this method as an optimization before attempting to dispatch the hook event.
Events
HookDisabled
An event which is raised when the global hook is disabled.
public event EventHandler<HookEventArgs>? HookDisabled
Event Type
Remarks
This event is raised when the Dispose() method is called.
HookEnabled
An event which is raised when the global hook is enabled.
public event EventHandler<HookEventArgs>? HookEnabled
Event Type
Remarks
This event is raised when the Run() or RunAsync() method is called.
KeyPressed
An event which is raised when a key is pressed.
public event EventHandler<KeyboardHookEventArgs>? KeyPressed
Event Type
KeyReleased
An event which is raised when a key is released.
public event EventHandler<KeyboardHookEventArgs>? KeyReleased
Event Type
KeyTyped
An event which is raised when a key is typed.
public event EventHandler<KeyboardHookEventArgs>? KeyTyped
Event Type
MouseClicked
An event which is raised when a mouse button is clicked.
public event EventHandler<MouseHookEventArgs>? MouseClicked
Event Type
MouseDragged
An event which is raised when the mouse cursor is dragged.
public event EventHandler<MouseHookEventArgs>? MouseDragged
Event Type
MouseMoved
An event which is raised when the mouse cursor is moved.
public event EventHandler<MouseHookEventArgs>? MouseMoved
Event Type
MousePressed
An event which is raised when a mouse button is pressed.
public event EventHandler<MouseHookEventArgs>? MousePressed
Event Type
MouseReleased
An event which is raised when a mouse button is released.
public event EventHandler<MouseHookEventArgs>? MouseReleased
Event Type
MouseWheel
An event which is raised when the mouse wheel is turned.
public event EventHandler<MouseWheelHookEventArgs>? MouseWheel