### Grant input permissions with udev rules Source: https://sharphook.tolik.io/articles/os-constraints.html Create a udev rule file at /etc/udev/rules.d/70-[your-app].rules to grant the current user access to input and uinput devices, then reload and trigger udev. The filename must start with a number less than 73 because rule 73 applies uaccess permissions. This is a development quickstart for Wayland or low-level X11 backends. ```text ACTION=="remove", GOTO="app_end" SUBSYSTEM=="input", KERNEL=="event*", TAG+="uaccess" KERNEL=="uinput", SUBSYSTEM=="misc", TAG+="uaccess" LABEL="app_end" ``` ```bash sudo udevadm control --reload-rules && sudo udevadm trigger ``` -------------------------------- ### CreateScreenInfo() Source: https://sharphook.tolik.io/api/SharpHook.Providers.IScreenInfoProvider.html Gets the information about screens. ```APIDOC ## CreateScreenInfo() ### Description Gets the information about screens. ### Method CreateScreenInfo ### Returns - **ScreenData[]** - The information about screens. ``` -------------------------------- ### GetLoadedLinuxBackend() Source: https://sharphook.tolik.io/api/SharpHook.Providers.ILinuxBackendProvider.html Gets the loaded Linux backend. ```APIDOC ## GetLoadedLinuxBackend() ### Description Gets the loaded Linux backend. ### Method GetLoadedLinuxBackend ### Signature ``` LinuxBackend GetLoadedLinuxBackend() ``` ### Returns - **LinuxBackend** - The loaded Linux backend. ### Remarks On Windows and macOS, this method always returns None. ``` -------------------------------- ### Install SharpHook packages with dotnet add package Source: https://sharphook.tolik.io/index.html Install the SharpHook packages via the .NET CLI. Each command adds a specific package: the core SharpHook package, the Reactive extension, the ReactiveUI extension, the R3 extension, and the Testing package. ```shell dotnet add package SharpHook ``` ```shell dotnet add package SharpHook.Reactive ``` ```shell dotnet add package SharpHook.ReactiveUI ``` ```shell dotnet add package SharpHook.R3 ``` ```shell dotnet add package SharpHook.Testing ``` -------------------------------- ### BeforeRun() Source: https://sharphook.tolik.io/api/SharpHook.BasicGlobalHookBase.html Defines actions to be done before the global hook is started. The default implementation does nothing. ```APIDOC ## BeforeRun() ### Description Defines actions to be done before the global hook is started. The default implementation does nothing. ### Method BeforeRun ### Signature protected virtual void BeforeRun() ``` -------------------------------- ### LogEntryParser.Instance Source: https://sharphook.tolik.io/api/SharpHook.Logging.LogEntryParser.html Gets the single instance of LogEntryParser. ```APIDOC ## Property: Instance ### Description Gets the single instance of LogEntryParser. ### Property Value - **LogEntryParser** - The single instance of LogEntryParser. ### Example ```csharp LogEntryParser parser = LogEntryParser.Instance; ``` ``` -------------------------------- ### GetLinuxMode() Source: https://sharphook.tolik.io/api/SharpHook.Providers.ILinuxBackendProvider.html Gets the mode for selecting which Linux backend to load. ```APIDOC ## GetLinuxMode() ### Description Gets the mode for selecting which Linux backend to load. ### Method GetLinuxMode ### Signature ``` LinuxMode GetLinuxMode() ``` ### Returns - **LinuxMode** - The mode for selecting which Linux backend to load. ### Remarks This method returns only the selection mode. If you need to get the Linux backend that was actually loaded, then use GetLoadedLinuxBackend(). On Windows and macOS, this method always returns AutoXRecord which is the default value. ``` -------------------------------- ### Subscribe to R3GlobalHook observables and run the hook Source: https://sharphook.tolik.io/articles/reactive.html Basic usage of SharpHook.R3's R3GlobalHook: subscribe to hook and event observables, then start the hook with Run or RunAsync. The hook must not be started while another global hook is running, and a disposed instance cannot be restarted. ```csharp using SharpHook.R3; var hook = new R3GlobalHook(); hook.HookEnabled.Subscribe(OnHookEnabled); hook.HookDisabled.Subscribe(OnHookDisabled); hook.KeyTyped.Subscribe(OnKeyTyped); hook.KeyPressed.Subscribe(OnKeyPressed); hook.KeyReleased.Subscribe(OnKeyReleased); hook.MouseClicked.Subscribe(OnMouseClicked); hook.MousePressed.Subscribe(OnMousePressed); hook.MouseReleased.Subscribe(OnMouseReleased); hook.MouseMoved.Subscribe(OnMouseMoved); hook.MouseMovedRelative.Subscribe(OnMouseMovedRelative); hook.MouseDragged.Subscribe(OnMouseDragged); hook.MouseDraggedRelative.Subscribe(OnMouseDraggedRelative); hook.MouseWheel.Subscribe(OnMouseWheel); hook.Run(); // or await hook.RunAsync(); ``` -------------------------------- ### Subscribe to ReactiveGlobalHook observables and run the hook Source: https://sharphook.tolik.io/articles/reactive.html Basic usage of SharpHook.Reactive's ReactiveGlobalHook: subscribe to event observables, then start the hook with Run() or RunAsync(). Requires the SharpHook.Reactive package. The observables emit EventArgs-derived types matching IGlobalHook events. Running the hook when already running is not allowed; IsRunning and Stop are available. Dispose stops the hook if running and completes all observables; starting a disposed instance is not allowed. ```csharp using SharpHook.Reactive; var hook = new ReactiveGlobalHook(); hook.HookEnabled.Subscribe(OnHookEnabled); hook.HookDisabled.Subscribe(OnHookDisabled); hook.KeyTyped.Subscribe(OnKeyTyped); hook.KeyPressed.Subscribe(OnKeyPressed); hook.KeyReleased.Subscribe(OnKeyReleased); hook.MouseClicked.Subscribe(OnMouseClicked); hook.MousePressed.Subscribe(OnMousePressed); hook.MouseReleased.Subscribe(OnMouseReleased); hook.MouseMoved.Subscribe(OnMouseMoved); hook.MouseMovedRelative.Subscribe(OnMouseMovedRelative); hook.MouseDragged.Subscribe(OnMouseDragged); hook.MouseDraggedRelative.Subscribe(OnMouseDraggedRelative); hook.MouseWheel.Subscribe(OnMouseWheel); hook.Run(); // or await hook.RunAsync(); ``` -------------------------------- ### Basic usage of EventLoopGlobalHook with IGlobalHook Source: https://sharphook.tolik.io/articles/hooks.html Shows how to create an EventLoopGlobalHook, subscribe to its events, and run it. KeyTyped is disabled by default. Run blocks the current thread; RunAsync runs on a separate thread and returns a Task. Subscribe to events after the hook is started. Running when already running throws an exception. ```csharp using SharpHook; var hook = new EventLoopGlobalHook(); // Events of type EventHandler: hook.HookEnabled += OnHookEnabled; hook.HookDisabled += OnHookDisabled; // Events of type EventHandler: hook.KeyTyped += OnKeyTyped; // Disabled by default hook.KeyPressed += OnKeyPressed; hook.KeyReleased += OnKeyReleased; // Events of type EventHandler: hook.MouseClicked += OnMouseClicked; hook.MousePressed += OnMousePressed; hook.MouseReleased += OnMouseReleased; hook.MouseMoved += OnMouseMoved; hook.MouseMovedRelative += OnMouseMovedRelative; hook.MouseDragged += OnMouseDragged; hook.MouseDraggedRelative += OnMouseDraggedRelative; // Events of type EventHandler: hook.MouseWheel += OnMouseWheel; hook.Run(); // or await hook.RunAsync(); ``` -------------------------------- ### ReactiveUIGlobalHook basic usage Source: https://sharphook.tolik.io/articles/reactive.html Basic usage of SharpHook.ReactiveUI: create a ReactiveUIGlobalHook, subscribe to its observables, and run it. The Run and RunAsync methods behave like IGlobalHook; running while already running is not allowed, and IsRunning is available. Dispose stops the hook if running and completes all observables; starting a disposed instance is not allowed. ```csharp using SharpHook.ReactiveUI; var hook = new ReactiveUIGlobalHook(); hook.HookEnabled.Subscribe(OnHookEnabled); hook.HookDisabled.Subscribe(OnHookDisabled); hook.KeyTyped.Subscribe(OnKeyTyped); hook.KeyPressed.Subscribe(OnKeyPressed); hook.KeyReleased.Subscribe(OnKeyReleased); hook.MouseClicked.Subscribe(OnMouseClicked); hook.MousePressed.Subscribe(OnMousePressed); hook.MouseReleased.Subscribe(OnMouseReleased); hook.MouseMoved.Subscribe(OnMouseMoved); hook.MouseMovedRelative.Subscribe(OnMouseMovedRelative); hook.MouseDragged.Subscribe(OnMouseDragged); hook.MouseDraggedRelative.Subscribe(OnMouseDraggedRelative); hook.MouseWheel.Subscribe(OnMouseWheel); hook.Run(); // or await hook.RunAsync(); __ ``` -------------------------------- ### EventSimulator.TextSimulationDelayOnLinux Source: https://sharphook.tolik.io/api/SharpHook.Simulation.EventSimulator.html Gets or sets the delay between simulating individual characters when simulating text on Linux. This property is ignored on Windows, macOS, and Wayland. ```APIDOC ## Property: TextSimulationDelayOnLinux ### Description Gets or sets the delay between simulating individual characters when simulating text on Linux. ### Signature public TimeSpan TextSimulationDelayOnLinux { get; set; } ### Property Value - **TimeSpan** - The delay between simulating individual characters when simulating text on Linux. ### Remarks X11 doesn't support simulating arbitrary Unicode characters directly. Instead, for each character, an unused key code is remapped to that character, and then key press/release is simulated. Since the receiving application must react to the remapping, and may not do so instantaneously, a delay is needed for accurate simulation. The default delay is 50 milliseconds. On Windows and macOS, as well as Wayland, this property is ignored. ### Exceptions - **ArgumentOutOfRangeException** - `value` represents a negative time span. ``` -------------------------------- ### InitializeVirtualDevices(string) Source: https://sharphook.tolik.io/api/SharpHook.Providers.UioHookProvider.html Initializes virtual input devices used for event simulation. ```APIDOC ## InitializeVirtualDevices(string) ### Description Initializes virtual input devices used for event simulation. ### Method InitializeVirtualDevices ### Endpoint InitializeVirtualDevices(string applicationName) ### Parameters - **applicationName** (string) - Required - The application name which is used to identify the virtual devices. ### Returns UioHookResult - The result of the operation. ### Remarks Virtual input devices are required on Linux when using a uinput-based backend. On Windows, macOS, and the XRecord-based X11 backend, this method does nothing and always returns Success. Initializing virtual input devices is expensive, so it should generally be done once early in the application's lifetime. If virtual devices are initialzed, then calling this method again will increase the reference counter – the devices will be destroyed only when the reference counter reaches zero, i.e., when the same number of calls to DestroyVirtualDevices() are made. ``` -------------------------------- ### InitializeVirtualDevices(string) Source: https://sharphook.tolik.io/api/SharpHook.Providers.IEventSimulationProvider.html Initializes virtual input devices used for event simulation. Returns the result of the operation. ```APIDOC ## InitializeVirtualDevices(string) ### Description Initializes virtual input devices used for event simulation. ### Method InitializeVirtualDevices(string) ### Signature UioHookResult InitializeVirtualDevices(string applicationName) ### Parameters - **applicationName** (string) - The application name which is used to identify the virtual devices. ### Returns - **UioHookResult** - The result of the operation. ### Remarks Virtual input devices are required on Linux when using a uinput-based backend. On Windows, macOS, and the XRecord-based X11 backend, this method does nothing and always returns Success. Initializing virtual input devices is expensive, so it should generally be done once early in the application's lifetime. If virtual devices are initialzed, then calling this method again will increase the reference counter – the devices will be destroyed only when the reference counter reaches zero, i.e., when the same number of calls to DestroyVirtualDevices() are made. ``` -------------------------------- ### Simulate keyboard and mouse events with EventSimulator Source: https://sharphook.tolik.io/articles/simulation.html Creates an EventSimulator and demonstrates simulating key presses, key strokes, mouse button presses/releases, mouse movement, and mouse wheel scrolling. The simulator is disposed at the end, which destroys virtual input devices on Linux. The application name is used to identify virtual devices and is truncated if longer than 62 characters. ```csharp using SharpHook; using SharpHook.Data; using var simulator = EventSimulator.Create("Your application name"); // Press Ctrl+C simulator.SimulateKeyPress(KeyCode.VcLeftControl); simulator.SimulateKeyPress(KeyCode.VcC); // Release Ctrl+C simulator.SimulateKeyRelease(KeyCode.VcC); simulator.SimulateKeyRelease(KeyCode.VcLeftControl); // Simulate pressing Ctrl, then pressing C, then releasing C, then releasing Ctrl simulator.SimulateKeyStroke(KeyCode.VcLeftControl, KeyCode.VcC); // Press the left mouse button simulator.SimulateMousePress(MouseButton.Button1); // Release the left mouse button simulator.SimulateMouseRelease(MouseButton.Button1); // Press the left mouse button at (0, 0) simulator.SimulateMousePress(0, 0, MouseButton.Button1); // Release the left mouse button at (0, 0) simulator.SimulateMouseRelease(0, 0, MouseButton.Button1); // Move the mouse pointer to (0, 0) simulator.SimulateMouseMovement(0, 0); // Move the mouse pointer 50 pixels to the right and 100 pixels down simulator.SimulateMouseMovementRelative(50, 100); // Scroll the mouse wheel simulator.SimulateMouseWheel( rotation: -120, direction: MouseWheelScrollDirection.Vertical, // Vertical by default type: MouseWheelScrollType.UnitScroll); // UnitScroll by default ``` -------------------------------- ### GetAutoRepeatRate() Source: https://sharphook.tolik.io/api/SharpHook.Providers.IKeyboardInfoProvider.html Gets the key auto-repeat rate. ```APIDOC ## GetAutoRepeatRate() ### Description Gets the key auto-repeat rate. ### Method GetAutoRepeatRate ### Signature int GetAutoRepeatRate() ### Returns - **int** - The key auto-repeat rate. ``` -------------------------------- ### Create(string, IEventSimulationProvider?) Source: https://sharphook.tolik.io/api/SharpHook.Simulation.EventSimulator.html Creates a new instance of the EventSimulator class. On Linux, this method also initializes virtual input devices for event simulation. ```APIDOC ## Create(string, IEventSimulationProvider?) ### Description Creates a new instance of the EventSimulator class. On Linux, this method also initializes virtual input devices for event simulation. ### Method Create ### Endpoint EventSimulator.Create(string applicationName, IEventSimulationProvider? simulationProvider = null) ### Parameters #### Parameters - **applicationName** (string) - Required - The application name which is used to identify the virtual input devices. A null or empty string is technically allowed, but not recommended. - **simulationProvider** (IEventSimulationProvider?) - Optional - The simulation functionality provider, or null to use the default one. ### Returns EventSimulator - A new instance of EventSimulator. ### Remarks Virtual input devices are required on Linux when using a uinput-based backend. On Windows, macOS, and the XRecord-based X11 backend, device initialization is a no-op. Initializing virtual devices is expensive, so it is recommended to reuse the same instance of EventSimulator. Virtual devices are destroyed when the EventSimulator instance is disposed. If an instance of EventSimulator is created when another instance is already active, virtual devices will not be initialized again. Instead, a reference counter will be incremented. Virtual devices will only be destroyed when all active instances of EventSimulator are disposed. ### Exceptions - **HookException** - Initialization of virtual devices on Linux has failed. ``` -------------------------------- ### Sequence() Source: https://sharphook.tolik.io/api/SharpHook.Simulation.EventSimulator.html Initializes a builder for a sequence of events that can be simulated together. ```APIDOC ## Sequence() ### Description Initializes a builder for a sequence of events that can be simulated together. ### Method Sequence ### Endpoint EventSimulator.Sequence() ### Parameters None ### Returns IEventSimulationSequenceBuilder - A builder for a sequence of events that can be simulated together. ### Remarks The builder is automatically disposed when this simulator is disposed or garbage-collected. ``` -------------------------------- ### GetAutoRepeatDelay() Source: https://sharphook.tolik.io/api/SharpHook.Providers.IKeyboardInfoProvider.html Gets the key auto-repeat delay. ```APIDOC ## GetAutoRepeatDelay() ### Description Gets the key auto-repeat delay. ### Method GetAutoRepeatDelay ### Signature int GetAutoRepeatDelay() ### Returns - **int** - The key auto-repeat delay. ``` -------------------------------- ### GetHashCode() Source: https://sharphook.tolik.io/api/SharpHook.Logging.LogEntry.html Gets the hash code of this LogEntry object. ```APIDOC ## GetHashCode() ### Description Gets the hash code of this object. ### Method `public override int GetHashCode()` ### Returns - `int` - The hash code of this object. ``` -------------------------------- ### KeyTyped Source: https://sharphook.tolik.io/api/SharpHook.R3.IR3GlobalHook.html Gets an observable which emits a value when a key is typed. ```APIDOC ## KeyTyped ### Description Gets an observable which emits a value when a key is typed. ### Property `Observable KeyTyped { get; }` ### Property Value - **Observable** - An observable which emits a value when a key is typed. ### Remarks This event is disabled by default. If you want to enable it, you should set the KeyTypedEnabled property to true. On Wayland, this event is not supported. You can use GetOptionalFeatureSupport() to check support for this event. If that method returns KeyTypedEvents as one of the supported features, then this event is supported. ``` -------------------------------- ### KeyReleased Source: https://sharphook.tolik.io/api/SharpHook.R3.IR3GlobalHook.html Gets an observable which emits a value when a key is released. ```APIDOC ## KeyReleased ### Description Gets an observable which emits a value when a key is released. ### Property `Observable KeyReleased { get; }` ### Property Value - **Observable** - An observable which emits a value when a key is released. ``` -------------------------------- ### Constructor R3LogSourceAdapter(ILogSource, TimeProvider?) Source: https://sharphook.tolik.io/api/SharpHook.R3.Logging.R3LogSourceAdapter.html Initializes a new instance of the R3LogSourceAdapter class with the specified log source and optional default time provider. ```APIDOC ## Constructor R3LogSourceAdapter(ILogSource, TimeProvider?) ### Description Initializes a new instance of the R3LogSourceAdapter class. ### Signature csharp public R3LogSourceAdapter(ILogSource logSource, TimeProvider? defaultTimeProvider = null) ### Parameters - **logSource** (ILogSource) - Required - The log source to adapt. - **defaultTimeProvider** (TimeProvider) - Optional - The default time provider for the observable, or null to use the default one (as defined in R3.ObservableSystem.DefaultTimeProvider). ### Exceptions - **ArgumentNullException** - Thrown when `logSource` is null. ``` -------------------------------- ### KeyPressed Source: https://sharphook.tolik.io/api/SharpHook.R3.IR3GlobalHook.html Gets an observable which emits a value when a key is pressed. ```APIDOC ## KeyPressed ### Description Gets an observable which emits a value when a key is pressed. ### Property `Observable KeyPressed { get; }` ### Property Value - **Observable** - An observable which emits a value when a key is pressed. ### Remarks On Wayland, this event is not raised repeatedly if the key is kept down. To check whether key auto-repeat events are reported, you can use GetOptionalFeatureSupport(). If that method returns KeyAutoRepeat as one of the supported features, then this event will be raised repeatedly if the key is kept down. ``` -------------------------------- ### EmptyLogSource Constructor Source: https://sharphook.tolik.io/api/SharpHook.Logging.EmptyLogSource.html Initializes a new instance of the EmptyLogSource class. ```APIDOC ## EmptyLogSource() ### Description Initializes a new instance of the EmptyLogSource class. ### Syntax ```csharp public EmptyLogSource() ``` ``` -------------------------------- ### Create and reuse an event simulation template with CreateTemplate Source: https://sharphook.tolik.io/articles/simulation.html Creates an immutable IEventSimulationSequenceTemplate from a sequence of mouse wheel events and simulates it multiple times. The template can be reused to simulate the same predetermined sequence repeatedly. ```csharp var diagonalScrollTemplate = simulator.Sequence() .AddMouseWheel(rotation: -120, direction: MouseWheelScrollDirection.Vertical) .AddMouseWheel(rotation: -120, direction: MouseWheelScrollDirection.Horizontal) .CreateTemplate(); diagonalScrollTemplate.Simulate(); diagonalScrollTemplate.Simulate(); diagonalScrollTemplate.Simulate(); ``` -------------------------------- ### IR3LogSource.MessageLogged Source: https://sharphook.tolik.io/api/SharpHook.R3.Logging.IR3LogSource.html Gets an observable that is emitted when libuiohook logs a message. ```APIDOC ## Property: MessageLogged ### Description An observable which is emitted when libuiohook logs a message. ### Property Value `Observable` ### Example ```csharp Observable messageLogged = source.MessageLogged; ``` ``` -------------------------------- ### Simulate a sequence of mouse events with IEventSimulator.Sequence Source: https://sharphook.tolik.io/articles/simulation.html Builds a sequence of mouse events and simulates them in one call. On Windows, all events are simulated in a single Windows API call; on macOS and Linux, events are simulated one-by-one but still more efficient than multiple PostEvent calls. Simulate returns UioHookResult; on Windows either all events are simulated or none, while on macOS/Linux a failure stops further events. ```csharp simulator.Sequence() .AddMouseMovementRelative(20, 20) .AddMousePress(MouseButton.Button1) .AddMouseRelease(MouseButton.Button1) .AddMouseMovementRelative(-20, -20) .Simulate(); ``` -------------------------------- ### UioHookProvider Class Source: https://sharphook.tolik.io/api/SharpHook.Providers.UioHookProvider.html Documentation for the UioHookProvider class, including its properties and remarks. ```APIDOC ## Class UioHookProvider ### Description A provider of low-level functionality which delegates it to libuiohook. ### Namespace SharpHook.Providers ### Assembly SharpHook.dll ### Inheritance object -> UioHookProvider ### Implements ILoggingProvider, IGlobalHookProvider, IEventSimulationProvider, IFeatureProvider, IAccessibilityProvider, ILinuxBackendProvider, IDeviceProcsProvider, IScreenInfoProvider, IKeyboardInfoProvider, IMouseInfoProvider ### Properties #### AxPollFrequency Gets or sets the frequency in seconds for polling the access to the macOS Accessibility API when the global hook is running. The default value is 1 second. - Type: uint - Remarks: On Windows and Linux, this property does nothing and always returns `0`. #### Instance Gets the single instance of UioHookProvider. - Type: UioHookProvider #### KeyTypedEnabled Gets or sets the value which indicates whether events of type KeyTyped are enabled. The default value is false. - Type: bool - Remarks: If the application doesn't use events of type KeyTyped, then they should be disabled so that there is no performance penalty and no subtle system-wide side effects. Support for events of type KeyTyped can be queried using GetOptionalFeatureSupport(). If that method returns KeyTypedEvents as one of its flags, then KeyTyped events are supported and can be enabled or disabled. On Wayland, this property does nothing since this feature is not supported. #### PostTextDelayLinux Gets or sets the delay (in nanoseconds) between posting individual characters when posting text on Linux. - Type: ulong - Remarks: X11 doesn't support posting arbitrary Unicode characters directly. Instead, for each character, an unused key code is remapped to that character, and then key press/release is simulated. Since the receiving application must react to the remapping, and may not do so instantaneously, a delay is needed for accurate simulation. The default delay is 50 milliseconds. On Windows and macOS, as well as Wayland, this property does nothing and always returns `0`. #### PromptUserIfAxApiDisabled Gets or sets the value which indicates whether global hooks or event simulation should prompt the user when they try to request access to macOS Accessibility API, and it is disabled. The default value is true. - Type: bool - Remarks: On Windows and Linux, this property does nothing and always returns false. ``` -------------------------------- ### LogEventArgs.LogEntry Property Source: https://sharphook.tolik.io/api/SharpHook.Logging.LogEventArgs.html Gets the entry of the current log event. ```APIDOC ## LogEntry Property ### Description Gets the entry of the current log event. ### Property Signature `public LogEntry LogEntry { get; }` ### Property Value - **LogEntry** - The entry of the current log event. ### See Also - ILogSource - LogSource - LogEntry ``` -------------------------------- ### MouseWheel Source: https://sharphook.tolik.io/api/SharpHook.R3.IR3GlobalHook.html Gets an observable that emits a value when the mouse wheel is scrolled. ```APIDOC ## MouseWheel ### Description Gets an observable which emits a value when the mouse wheel is scrolled. ### Property ```csharp Observable MouseWheel { get; } ``` ### Property Value - **Observable** - An observable which emits a value when the mouse wheel is scrolled. ### Remarks On Wayland, this event does not include mouse coordinates (they are always set to (0, 0)). To check whether mouse coordinates for this event are available, you can use GetOptionalFeatureSupport(). If that method returns AbsoluteMouseButtonCoordinates as one of the supported features, then this event will contain non-zero mouse coordinates. ``` -------------------------------- ### SetLinuxMode() method Source: https://sharphook.tolik.io/api/SharpHook.Providers.UioHookProvider.html Sets the Linux backend selection mode. Returns Success, Failure for invalid enum, or ErrorLinuxBackend if a backend is already loaded. ```csharp public UioHookResult SetLinuxMode(LinuxMode mode)__ ``` -------------------------------- ### MouseReleased Source: https://sharphook.tolik.io/api/SharpHook.R3.IR3GlobalHook.html Gets an observable that emits a value when a mouse button is released. ```APIDOC ## MouseReleased ### Description Gets an observable which emits a value when a mouse button is released. ### Property ```csharp Observable MouseReleased { get; } ``` ### Property Value - **Observable** - An observable which emits a value when a mouse button is released. ### Remarks On Wayland, this event does not include mouse coordinates (they are always set to (0, 0)). To check whether mouse coordinates for this event are available, you can use GetOptionalFeatureSupport(). If that method returns AbsoluteMouseButtonCoordinates as one of the supported features, then this event will contain non-zero mouse coordinates. ``` -------------------------------- ### EventSimulationSequenceTemplate(EventSimulator, IEnumerable) Source: https://sharphook.tolik.io/api/SharpHook.Simulation.EventSimulationSequenceTemplate.html Constructor for creating a new EventSimulationSequenceTemplate instance. ```APIDOC ## [Constructor] EventSimulationSequenceTemplate(EventSimulator, IEnumerable) ### Description Initializes a new instance of the EventSimulationSequenceTemplate class. The events are copied to ensure they don't change. ### Method Constructor ### Signature `public EventSimulationSequenceTemplate(EventSimulator owner, IEnumerable events)` ### Parameters - **owner** (EventSimulator) - Required - The owner of this template. If the owner is disposed, this instance becomes instantly disposed as well. - **events** (IEnumerable) - Required - The events to simulate. They will be copied to ensure the events don't change. ### Exceptions - **ArgumentNullException** - Thrown when `owner` or `events` is null. ### Remarks If `owner` is disposed, then this instance becomes instantly disposed as well. ``` -------------------------------- ### MousePressed Source: https://sharphook.tolik.io/api/SharpHook.R3.IR3GlobalHook.html Gets an observable that emits a value when a mouse button is pressed. ```APIDOC ## MousePressed ### Description Gets an observable which emits a value when a mouse button is pressed. ### Property ```csharp Observable MousePressed { get; } ``` ### Property Value - **Observable** - An observable which emits a value when a mouse button is pressed. ### Remarks On Wayland, this event does not include mouse coordinates (they are always set to (0, 0)). To check whether mouse coordinates for this event are available, you can use GetOptionalFeatureSupport(). If that method returns AbsoluteMouseButtonCoordinates as one of the supported features, then this event will contain non-zero mouse coordinates. ``` -------------------------------- ### LogEntry Constructor Source: https://sharphook.tolik.io/api/SharpHook.Logging.LogEntry.html Initializes a new instance of the LogEntry class with the specified log level, full text, format, native format, arguments, raw arguments, and argument placeholders. ```APIDOC ## LogEntry(LogLevel, string, string, string, IReadOnlyList, IReadOnlyList, IReadOnlyList) ### Description Initializes a new instance of the LogEntry class with the specified log level, full text, format, native format, arguments, raw arguments, and argument placeholders. ### Method Constructor ### Signature public LogEntry(LogLevel level, string fullText, string format, string nativeFormat, IReadOnlyList arguments, IReadOnlyList rawArguments, IReadOnlyList argumentPlaceholders) ### Parameters - **level** (LogLevel) - Required - The log level. - **fullText** (string) - Required - The full text of the log entry. - **format** (string) - Required - The format of the log entry which can be used in `String.Format`. - **nativeFormat** (string) - Required - The native format of the log entry. - **arguments** (IReadOnlyList) - Required - The arguments of the log entry which can be used in `String.Format`. - **rawArguments** (IReadOnlyList) - Required - The arguments as they appear in the entry's full text. - **argumentPlaceholders** (IReadOnlyList) - Required - The argument placeholders from the native format. ### Remarks For simple handling the Level and FullText properties are enough. For more advanced handling you can use the entries' formats and arguments. Each log entry from libuiohook has the following format: `function [line]: message`. The function and line reference the source code of libuiohook itself, and can be retrieved using the Function and SourceLine properties. The message can be retrieved by splitting the text by `:` and getting the trimmed second part. You shouldn't create LogEntry instances yourself. Instead, use the LogEntryParser class to create them in the logging callback. ``` -------------------------------- ### MouseMoved Source: https://sharphook.tolik.io/api/SharpHook.R3.IR3GlobalHook.html Gets an observable that emits a value when the mouse cursor is moved. ```APIDOC ## MouseMoved ### Description Gets an observable which emits a value when the mouse cursor is moved. ### Property ```csharp Observable MouseMoved { get; } ``` ### Property Value - **Observable** - An observable which emits a value when the mouse cursor is moved. ### Remarks On Wayland, this event is raised only when using an absolute pointing device (like a touchscreen or a mouse in a virtual machine). Relative pointing devices (like most normal mice) will raise MouseMovedRelative instead. ``` -------------------------------- ### MouseDragged Source: https://sharphook.tolik.io/api/SharpHook.R3.IR3GlobalHook.html Gets an observable which emits a value when the mouse cursor is dragged. ```APIDOC ## MouseDragged ### Description Gets an observable which emits a value when the mouse cursor is dragged. ### Property `Observable MouseDragged { get; }` ### Property Value - **Observable** - An observable which emits a value when the mouse cursor is dragged. ### Remarks On Wayland, this event is raised only when using an absolute pointing device (like a touchscreen or a mouse in a virtual machine). Relative pointing devices (like most normal mice) will raise MouseDraggedRelative instead. ``` -------------------------------- ### MouseClicked Source: https://sharphook.tolik.io/api/SharpHook.R3.IR3GlobalHook.html Gets an observable which emits a value when a mouse button is clicked. ```APIDOC ## MouseClicked ### Description Gets an observable which emits a value when a mouse button is clicked. ### Property `Observable MouseClicked { get; }` ### Property Value - **Observable** - An observable which emits a value when a mouse button is clicked. ### Remarks On Wayland, this event does not include mouse coordinates (they are always set to (0, 0)). To check whether mouse coordinates for this event are available, you can use GetOptionalFeatureSupport(). If that method returns AbsoluteMouseButtonCoordinates as one of the supported features, then this event will contain non-zero mouse coordinates. ``` -------------------------------- ### RunKeyboard() Source: https://sharphook.tolik.io/api/SharpHook.Providers.IGlobalHookProvider.html Runs the global hook only for keyboard events and blocks the thread until it's stopped. ```APIDOC ## RunKeyboard() ### Description Runs the global hook only for keyboard events and blocks the thread until it's stopped. ### Method RunKeyboard ### Signature UioHookResult RunKeyboard() ### Returns - **UioHookResult** - The result of the operation. ``` -------------------------------- ### HookEnabled Source: https://sharphook.tolik.io/api/SharpHook.R3.IR3GlobalHook.html Gets an observable which emits a value when the global hook is enabled. ```APIDOC ## HookEnabled ### Description Gets an observable which emits a value when the global hook is enabled. ### Property `Observable HookEnabled { get; }` ### Property Value - **Observable** - An observable which emits a value when the global hook is enabled. ### Remarks The observable emits a value when the Run(GlobalHookType) or RunAsync(GlobalHookType, bool) method is called. ``` -------------------------------- ### BasicGlobalHookBase(IGlobalHookProvider?) Source: https://sharphook.tolik.io/api/SharpHook.BasicGlobalHookBase.html Initializes a new instance of BasicGlobalHookBase with an optional global hook provider. ```APIDOC ## BasicGlobalHookBase(IGlobalHookProvider?) ### Description Initializes a new instance of BasicGlobalHookBase. ### Method Constructor ### Parameters - **globalHookProvider** (IGlobalHookProvider) - Optional - The underlying global hook provider, or null to use the default one. ### Remarks This constructor is protected and can only be called from derived classes. ``` -------------------------------- ### HookDisabled Source: https://sharphook.tolik.io/api/SharpHook.R3.IR3GlobalHook.html Gets an observable which emits a value when the global hook is disabled. ```APIDOC ## HookDisabled ### Description Gets an observable which emits a value when the global hook is disabled. ### Property `Observable HookDisabled { get; }` ### Property Value - **Observable** - An observable which emits a value when the global hook is disabled. ### Remarks The observable emits a value when the Stop() or Dispose() method is called. ``` -------------------------------- ### ReactiveLogSourceAdapter(ILogSource, IScheduler?) Source: https://sharphook.tolik.io/api/SharpHook.Reactive.Logging.ReactiveLogSourceAdapter.html Initializes a new instance of the ReactiveLogSourceAdapter class with the specified log source and optional default scheduler. ```APIDOC ## Constructor: ReactiveLogSourceAdapter(ILogSource, IScheduler?) ### Description Initializes a new instance of the ReactiveLogSourceAdapter class. ### Signature ```csharp public ReactiveLogSourceAdapter(ILogSource logSource, IScheduler? defaultScheduler = null) ``` ### Parameters - **logSource** (ILogSource) - Required - The log source to adapt. - **defaultScheduler** (IScheduler) - Optional - The default scheduler for the observable, or null to use the default one (System.Reactive.Concurrency.Scheduler.Immediate). ### Exceptions - **ArgumentNullException** - `logSource` is null. ``` -------------------------------- ### ToString() Source: https://sharphook.tolik.io/api/SharpHook.Logging.LogEntry.html Gets the string representation of the log entry, which is its full text. ```APIDOC ## ToString() ### Description Gets the string representation of the log entry i.e. its full text. ### Method `public override string ToString()` ### Returns - `string` - The full text of the log entry. ``` -------------------------------- ### Run() method signature Source: https://sharphook.tolik.io/api/SharpHook.Providers.UioHookProvider.html Runs the global hook and blocks the thread until it's stopped. ```csharp public UioHookResult Run() ``` -------------------------------- ### IsRunning Source: https://sharphook.tolik.io/api/SharpHook.BasicGlobalHookBase.html Gets the value which indicates whether the global hook is running. ```APIDOC ## IsRunning ### Description Gets the value which indicates whether the global hook is running. ### Property Value - **bool** - true if the global hook is running. Otherwise, false. ``` -------------------------------- ### Simulate() Source: https://sharphook.tolik.io/api/SharpHook.Simulation.IEventSimulationSequenceBuilder.html Simulates the events in this sequence. ```APIDOC ## Simulate() ### Description Simulates the events in this sequence. ### Method Simulate() ### Signature UioHookResult Simulate() ### Returns - **UioHookResult** - The result of the operation. ### Exceptions - **ObjectDisposedException** - The builder has been disposed. ``` -------------------------------- ### RunMouse() method Source: https://sharphook.tolik.io/api/SharpHook.Providers.UioHookProvider.html Runs the global hook only for mouse events and blocks the thread until stopped. On Windows, only a mouse hook is created; on macOS and Linux, filtering is used, and on Wayland the compositor connection is established. ```csharp public UioHookResult RunMouse()__ ``` -------------------------------- ### IsDisposed Source: https://sharphook.tolik.io/api/SharpHook.BasicGlobalHookBase.html Gets the value which indicates whether the global hook has been disposed. ```APIDOC ## IsDisposed ### Description Gets the value which indicates whether the global hook has been disposed. ### Property Value - **bool** - true if the global hook has been disposed. Otherwise, false. ### Remarks A disposed global hook cannot be started again. ``` -------------------------------- ### SimulateKeyRelease(KeyCode) Source: https://sharphook.tolik.io/api/SharpHook.Simulation.EventSimulator.html Simulates releasing a key. ```APIDOC ## SimulateKeyRelease(KeyCode) ### Description Simulates releasing a key. ### Method SimulateKeyRelease ### Endpoint EventSimulator.SimulateKeyRelease(KeyCode keyCode) ### Parameters #### Parameters - **keyCode** (KeyCode) - Required - The code of the key to release. ### Returns UioHookResult - The result of the operation. ``` -------------------------------- ### IsDisposed Property Source: https://sharphook.tolik.io/api/SharpHook.Reactive.Logging.ReactiveLogSourceAdapter.html Gets a value indicating whether the log source is disposed. ```APIDOC ## Property: IsDisposed ### Description Gets the value which indicates whether the log source is disposed. ### Signature ```csharp public bool IsDisposed { get; } ``` ### Property Value - **bool** - true if the log source is disposed. Otherwise, false. ### Remarks The MessageLogged observable doesn't emit any values in a disposed log source. ``` -------------------------------- ### Simulate() Source: https://sharphook.tolik.io/api/SharpHook.Simulation.EventSimulationSequenceTemplate.html Simulates the predetermined sequence of events and returns the result. ```APIDOC ## [Method] Simulate() ### Description Simulates the predetermined sequence of events. ### Method Signature `public UioHookResult Simulate()` ### Parameters None. ### Returns - **UioHookResult** - The result of the operation. ### Exceptions - **ObjectDisposedException** - Thrown when the template is disposed. ``` -------------------------------- ### Property IsDisposed Source: https://sharphook.tolik.io/api/SharpHook.R3.Logging.R3LogSourceAdapter.html Gets a value indicating whether the log source is disposed. ```APIDOC ## Property IsDisposed ### Description Gets the value which indicates whether the log source is disposed. ### Signature csharp public bool IsDisposed { get; } ### Property Value - **bool** - true if the log source is disposed. Otherwise, false. ### Remarks The MessageLogged observable doesn't emit any values in a disposed log source. ``` -------------------------------- ### LogSource.RegisterOrGet(ILoggingProvider, LogLevel) Source: https://sharphook.tolik.io/api/SharpHook.Logging.LogSource.html Creates and registers a source of libuiohook logs or returns the registered instance, using a specified logging provider. A single instance can be registered regardless of the provider. ```APIDOC ## RegisterOrGet(ILoggingProvider, LogLevel) ### Description Creates and registers a source of libuiohook logs or returns the registered instance, using a specified logging provider. ### Method RegisterOrGet ### Signature public static LogSource RegisterOrGet(ILoggingProvider loggingProvider, LogLevel minLevel = LogLevel.Info) ### Parameters - `loggingProvider` (ILoggingProvider) - Required - The logging provider used to register the log source. - `minLevel` (LogLevel) - Optional - The minimum log level. ### Returns LogSource - A source of libuiohook logs. ### Exceptions - ArgumentNullException - `loggingProvider` is null. ``` -------------------------------- ### LogSource.MinLevel Property Source: https://sharphook.tolik.io/api/SharpHook.Logging.LogSource.html Gets or sets the minimum log level for the log source. ```APIDOC ## MinLevel Property ### Description Gets or sets the minimum log level. ### Property Value LogLevel - The minimum log level. ``` -------------------------------- ### Dispose() Source: https://sharphook.tolik.io/api/SharpHook.Simulation.EventSimulator.html Disposes of the event simulator and destroys virtual input devices on Linux. ```APIDOC ## Dispose() ### Description Disposes of the event simulator and destroys virtual input devices on Linux. ### Method Dispose ### Endpoint EventSimulator.Dispose() ### Parameters None ### Returns void ### Remarks This method also disposes of any IEventSimulationSequenceBuilder and IEventSimulationSequenceTemplate instances owned by this event simulator. Virtual devices are destroyed only when all active instances of EventSimulator are disposed. ### Exceptions - **HookException** - Destroying virtual devices on Linux has failed. ``` -------------------------------- ### Dispose(bool) Source: https://sharphook.tolik.io/api/SharpHook.TaskPoolGlobalHook.html Destroys the global hook. After calling this method, the hook cannot be started again. ```APIDOC ## Dispose(bool disposing) ### Description Destroys the global hook. After calling this method, the hook cannot be started again. If you want to do that, create a new instance of IGlobalHook. ### Parameters - **disposing** (bool) - Required - true if the method is called from the Dispose() method. Otherwise, false. ### Exceptions - **HookException** - Stopping the hook has failed. ``` -------------------------------- ### SimulateMouseMovement(short, short) Source: https://sharphook.tolik.io/api/SharpHook.Simulation.EventSimulator.html Simulates moving a mouse pointer. ```APIDOC ## SimulateMouseMovement(short, short) ### Description Simulates moving a mouse pointer. ### Method SimulateMouseMovement ### Endpoint EventSimulator.SimulateMouseMovement(short x, short y) ### Parameters #### Parameters - **x** (short) - Required - The target X-coordinate of the mouse pointer. - **y** (short) - Required - The target Y-coordinate of the mouse pointer. ### Returns UioHookResult - The result of the operation. ``` -------------------------------- ### SimulateKeyPress(KeyCode) Source: https://sharphook.tolik.io/api/SharpHook.Simulation.EventSimulator.html Simulates pressing a key. ```APIDOC ## SimulateKeyPress(KeyCode) ### Description Simulates pressing a key. ### Method SimulateKeyPress ### Endpoint EventSimulator.SimulateKeyPress(KeyCode keyCode) ### Parameters #### Parameters - **keyCode** (KeyCode) - Required - The code of the key to press. ### Returns UioHookResult - The result of the operation. ``` -------------------------------- ### MouseMovedRelative Source: https://sharphook.tolik.io/api/SharpHook.R3.IR3GlobalHook.html Gets an observable that emits a value when the mouse cursor is moved relatively to its previous position. ```APIDOC ## MouseMovedRelative ### Description Gets an observable which emits a value when the mouse cursor is moved relatively to its previous position. ### Property ```csharp Observable MouseMovedRelative { get; } ``` ### Property Value - **Observable** - An observable which emits a value when the mouse cursor is moved relatively to its previous position. ### Remarks This event is raised only on Wayland when using a relative pointing device (which most normal mice are). To check whether the current platform can raise this event, you can use GetOptionalFeatureSupport(). If that method does not return AbsoluteMouseMovement as one of the supported features, then the current platform may raise this event. ``` -------------------------------- ### PostText(string) method signature Source: https://sharphook.tolik.io/api/SharpHook.Providers.UioHookProvider.html Simulates input of arbitrary Unicode characters. Supports full UTF-16 including surrogate pairs. On Linux, text simulation is slow and not guaranteed correct; PostTextDelayLinux can adjust the delay (default 50 ms). ```csharp public UioHookResult PostText(string text) ``` -------------------------------- ### MouseDraggedRelative Source: https://sharphook.tolik.io/api/SharpHook.R3.IR3GlobalHook.html Gets an observable which emits a value when the mouse cursor is dragged relatively to its previous position. ```APIDOC ## MouseDraggedRelative ### Description Gets an observable which emits a value when the mouse cursor is dragged relatively to its previous position. ### Property `Observable MouseDraggedRelative { get; }` ### Property Value - **Observable** - An observable which emits a value when the mouse cursor is dragged relatively to its previous position. ### Remarks This event is raised only on Wayland when using a relative pointing device (which most normal mice are). To check whether the current platform can raise this event, you can use GetOptionalFeatureSupport(). If that method does not return AbsoluteMouseMovement as one of the supported features, then the current platform may raise this event. ``` -------------------------------- ### Enum LinuxBackend Source: https://sharphook.tolik.io/api/SharpHook.Data.LinuxBackend.html Enumeration of available Linux backends for SharpHook, with values representing different backend implementations. ```APIDOC ## Enum LinuxBackend ### Description Represents a libuiohook backend that can be loaded on Linux. ### Fields - **None** = 0 - No backend has been loaded yet, and changing the backend mode is possible. - **Wayland** = 3 - The Wayland backend which uses libinput to listen to events and uinput to post events. This backend requires elevated privileges to work. - **X11** = 2 - The X11 backend which uses libinput to listen to events and uinput to post events. This backend requires elevated privileges to work. - **XRecord** = 1 - The X11 backend which uses XRecord to listen to events and XTest to post events. This backend represents the behaviour of SharpHook prior to version 8, and is the default backend on X11. ### See Also - LinuxMode ``` -------------------------------- ### KeyTypedEnabled Property Source: https://sharphook.tolik.io/api/SharpHook.Providers.IGlobalHookProvider.html Gets or sets the value which indicates whether events of type KeyTyped are enabled. ```APIDOC ## KeyTypedEnabled Property ### Description Gets or sets the value which indicates whether events of type KeyTyped are enabled. The default value is false. ### Property Signature bool KeyTypedEnabled { get; set; } ### Property Value - **bool** - true if events of type KeyTyped are enabled. Otherwise, false. ### Remarks If the application doesn't use events of type KeyTyped, then they should be disabled so that there is no performance penalty and no subtle system-wide side effects. Support for events of type KeyTyped can be queried using GetOptionalFeatureSupport(). If that method returns KeyTypedEvents as one of its flags, then KeyTyped events are supported and can be enabled or disabled. On Wayland, this property does nothing since this feature is not supported. ``` -------------------------------- ### MouseReleased Source: https://sharphook.tolik.io/api/SharpHook.R3.R3GlobalHookAdapter.html Gets an observable that emits when a mouse button is released. On Wayland, mouse coordinates may not be included. ```APIDOC ## MouseReleased ### Description Gets an observable which emits a value when a mouse button is released. ### Property Value - **Observable** - An observable which emits a value when a mouse button is released. ### Remarks On Wayland, this event does not include mouse coordinates (they are always set to (0, 0)). To check whether mouse coordinates for this event are available, you can use GetOptionalFeatureSupport(). If that method returns AbsoluteMouseButtonCoordinates as one of the supported features, then this event will contain non-zero mouse coordinates. ### Code Example ```csharp public Observable MouseReleased { get; } ``` ``` -------------------------------- ### Run() Source: https://sharphook.tolik.io/api/SharpHook.Providers.IGlobalHookProvider.html Runs the global hook and blocks the thread until it's stopped. ```APIDOC ## Run() ### Description Runs the global hook and blocks the thread until it's stopped. ### Method Run ### Signature UioHookResult Run() ### Returns - **UioHookResult** - The result of the operation. ``` -------------------------------- ### IReactiveGlobalHook.MouseWheel Source: https://sharphook.tolik.io/api/SharpHook.Reactive.IReactiveGlobalHook.html Gets an observable that emits when the mouse wheel is scrolled. On Wayland, mouse coordinates may not be included. ```APIDOC ## Property: MouseWheel ### Description Gets an observable which emits a value when the mouse wheel is scrolled. ### Property Value - **Type**: `IObservable` - **Description**: An observable which emits a value when the mouse wheel is scrolled. ### Remarks On Wayland, this event does not include mouse coordinates (they are always set to (0, 0)). To check whether mouse coordinates for this event are available, you can use `GetOptionalFeatureSupport()`. If that method returns `AbsoluteMouseButtonCoordinates` as one of the supported features, then this event will contain non-zero mouse coordinates. ``` -------------------------------- ### Simulate() Source: https://sharphook.tolik.io/api/SharpHook.Simulation.IEventSimulationSequenceTemplate.html Simulates the predetermined sequence of events. Returns the result of the operation as a UioHookResult. ```APIDOC ## Simulate() ### Description Simulates the predetermined sequence of events. ### Method Simulate ### Signature UioHookResult Simulate() ### Returns - **UioHookResult** - The result of the operation. ### Exceptions - **ObjectDisposedException** - The builder has been disposed. ```