Interface IBasicGlobalHook
- Namespace
- SharpHook
- Assembly
- SharpHook.dll
Represents basic operations for a global keyboard and mouse hook regardless of the form of its events.
public interface IBasicGlobalHook : IDisposable
- Inherited Members
Remarks
It is highly recommended not to implement this interface directly. If you want to create a custom global hook, you should instead extend the BasicGlobalHookBase class as it correctly implements the invariants required for advanced scenarios.
Properties
IsDisposed
Gets the value which indicates whether the global hook has been disposed.
bool IsDisposed { get; }
Property Value
Remarks
A disposed global hook cannot be started again.
IsRunning
Gets the value which indicates whether the global hook is running.
bool IsRunning { get; }
Property Value
Methods
Run()
Runs the global hook on the current thread, blocking it. The hook can be stopped temporarily by calling Stop() or stopped permanently by calling Dispose().
void Run()
Exceptions
- 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 stopped temporarily by calling Stop() or stopped permanently by calling Dispose().
Task RunAsync()
Returns
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.
Stop()
Stops the global hook.
void Stop()
Remarks
After stopping, the global hook can run again.
Exceptions
- ObjectDisposedException
The global hook has been disposed.