Table of Contents

Interface IGlobalHook

Namespace
SharpHook
Assembly
SharpHook.dll

Represents a global keyboard and mouse hook.

public interface IGlobalHook : IDisposable
Inherited Members

Properties

IsDisposed

Gets the value which indicates whether the global hook is disposed.

bool IsDisposed { get; }

Property Value

bool

true if the global hook is disposed. Otherwise, false.

Remarks

A disposed global hook cannot be started again.

See Also

IsRunning

Gets the value which indicates whether the global hook is running.

bool IsRunning { get; }

Property Value

bool

true if the global hook is running. Otherwise, false.

See Also

Methods

Run()

Runs the global hook on the current thread, blocking it. The hook can be destroyed by calling the Dispose() method.

void Run()

Exceptions

HookException

Starting the global hook has failed.

InvalidOperationException

The global hook is already running.

ObjectDisposedException

The global hook has been disposed.

See Also

RunAsync()

Runs the global hook without blocking the current thread. The hook can be destroyed by calling the Dispose() method.

Task RunAsync()

Returns

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

HookException

Starting the global hook has failed.

InvalidOperationException

The global hook is already running.

ObjectDisposedException

The global hook has been disposed.

See Also

Events

HookDisabled

An event which is raised when the global hook is disabled.

event EventHandler<HookEventArgs> HookDisabled

Event Type

EventHandler<HookEventArgs>

Remarks

This event is raised when the Dispose() method is called.

See Also

HookEnabled

An event which is raised when the global hook is enabled.

event EventHandler<HookEventArgs> HookEnabled

Event Type

EventHandler<HookEventArgs>

Remarks

This event is raised when the Run() or RunAsync() method is called.

See Also

KeyPressed

An event which is raised when a key is pressed.

event EventHandler<KeyboardHookEventArgs> KeyPressed

Event Type

EventHandler<KeyboardHookEventArgs>
See Also

KeyReleased

An event which is raised when a key is released.

event EventHandler<KeyboardHookEventArgs> KeyReleased

Event Type

EventHandler<KeyboardHookEventArgs>
See Also

KeyTyped

An event which is raised when a key is typed.

event EventHandler<KeyboardHookEventArgs> KeyTyped

Event Type

EventHandler<KeyboardHookEventArgs>
See Also

MouseClicked

An event which is raised when a mouse button is clicked.

event EventHandler<MouseHookEventArgs> MouseClicked

Event Type

EventHandler<MouseHookEventArgs>
See Also

MouseDragged

An event which is raised when the mouse cursor is dragged.

event EventHandler<MouseHookEventArgs> MouseDragged

Event Type

EventHandler<MouseHookEventArgs>
See Also

MouseMoved

An event which is raised when the mouse cursor is moved.

event EventHandler<MouseHookEventArgs> MouseMoved

Event Type

EventHandler<MouseHookEventArgs>
See Also

MousePressed

An event which is raised when a mouse button is pressed.

event EventHandler<MouseHookEventArgs> MousePressed

Event Type

EventHandler<MouseHookEventArgs>
See Also

MouseReleased

An event which is raised when a mouse button is released.

event EventHandler<MouseHookEventArgs> MouseReleased

Event Type

EventHandler<MouseHookEventArgs>
See Also

MouseWheel

An event which is raised when the mouse wheel is scrolled.

event EventHandler<MouseWheelHookEventArgs> MouseWheel

Event Type

EventHandler<MouseWheelHookEventArgs>
See Also

See Also