Interface IGlobalHook
Represents a global keyboard and mouse hook.
Inherited Members
Namespace: SharpHook
Assembly: SharpHook.dll
Syntax
public interface IGlobalHook : IDisposable
Properties
| Improve this Doc View SourceIsDisposed
Gets the value which indicates whether the global hook is disposed.
Declaration
bool IsDisposed { get; }
Property Value
Type | Description |
---|---|
Boolean | true if the global hook is disposed. Otherwise, false. |
Remarks
A disposed global hook cannot be started again.
IsRunning
Gets the value which indicates whether the global hook is running.
Declaration
bool IsRunning { get; }
Property Value
Type | Description |
---|---|
Boolean | true if the global hook is running. Otherwise, false. |
Methods
| Improve this Doc View SourceRun()
Runs the global hook on the current thread, blocking it. The hook can be destroyed by calling the Dispose() method.
Declaration
void Run()
Exceptions
Type | Condition |
---|---|
HookException | Starting the global hook has failed. |
InvalidOperationException | The global hook is already running. |
ObjectDisposedException | The global hook has been disposed. |
RunAsync()
Runs the global hook without blocking the current thread. The hook can be destroyed by calling the Dispose() method.
Declaration
Task RunAsync()
Returns
Type | Description |
---|---|
Task | A Task which finishes when the hook is destroyed. |
Remarks
Since the underlying native API for running a global hook is blocking, the only way to run it without blocking the current thread is to run it on a separate thread.
Exceptions
Type | Condition |
---|---|
HookException | Starting the global hook has failed. |
InvalidOperationException | The global hook is already running. |
ObjectDisposedException | The global hook has been disposed. |
Events
| Improve this Doc View SourceHookDisabled
An event which is raised when the global hook is disabled.
Declaration
event EventHandler<HookEventArgs> HookDisabled
Event Type
Type | Description |
---|---|
EventHandler<HookEventArgs> |
Remarks
This event is raised when the Dispose() method is called.
HookEnabled
An event which is raised when the global hook is enabled.
Declaration
event EventHandler<HookEventArgs> HookEnabled
Event Type
Type | Description |
---|---|
EventHandler<HookEventArgs> |
Remarks
This event is raised when the Run() or RunAsync() method is called.
KeyPressed
An event which is raised when a key is pressed.
Declaration
event EventHandler<KeyboardHookEventArgs> KeyPressed
Event Type
Type | Description |
---|---|
EventHandler<KeyboardHookEventArgs> |
KeyReleased
An event which is raised when a key is released.
Declaration
event EventHandler<KeyboardHookEventArgs> KeyReleased
Event Type
Type | Description |
---|---|
EventHandler<KeyboardHookEventArgs> |
KeyTyped
An event which is raised when a key is typed.
Declaration
event EventHandler<KeyboardHookEventArgs> KeyTyped
Event Type
Type | Description |
---|---|
EventHandler<KeyboardHookEventArgs> |
MouseClicked
An event which is raised when a mouse button is clicked.
Declaration
event EventHandler<MouseHookEventArgs> MouseClicked
Event Type
Type | Description |
---|---|
EventHandler<MouseHookEventArgs> |
MouseDragged
An event which is raised when the mouse cursor is dragged.
Declaration
event EventHandler<MouseHookEventArgs> MouseDragged
Event Type
Type | Description |
---|---|
EventHandler<MouseHookEventArgs> |
MouseMoved
An event which is raised when the mouse cursor is moved.
Declaration
event EventHandler<MouseHookEventArgs> MouseMoved
Event Type
Type | Description |
---|---|
EventHandler<MouseHookEventArgs> |
MousePressed
An event which is raised when a mouse button is pressed.
Declaration
event EventHandler<MouseHookEventArgs> MousePressed
Event Type
Type | Description |
---|---|
EventHandler<MouseHookEventArgs> |
MouseReleased
An event which is raised when a mouse button is released.
Declaration
event EventHandler<MouseHookEventArgs> MouseReleased
Event Type
Type | Description |
---|---|
EventHandler<MouseHookEventArgs> |
MouseWheel
An event which is raised when the mouse wheel is scrolled.
Declaration
event EventHandler<MouseWheelHookEventArgs> MouseWheel
Event Type
Type | Description |
---|---|
EventHandler<MouseWheelHookEventArgs> |