Table of Contents

Interface IEventSimulationProvider

Namespace
SharpHook.Providers
Assembly
SharpHook.dll

Represents a provider of low-level event simulation functionality.

public interface IEventSimulationProvider

Methods

GetPostTextDelayX11()

Gets the delay (in nanoseconds) between posting individual characters when posting text on Linux.

ulong GetPostTextDelayX11()

Returns

ulong

The delay (in nanoseconds) between posting individual characters when posting text on Linux.

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 this method always returns 0.

See Also

PostEvent(ref UioHookEvent)

Posts a fake input event.

UioHookResult PostEvent(ref UioHookEvent e)

Parameters

e UioHookEvent

The event to post.

Returns

UioHookResult

The result of the operation.

Remarks

The instance of the event doesn't need all fields to have value. Only Type, Keyboard/Mouse/Wheel should be present.

The following table describes the specifics of simulating each event type.

Event typeDescription
HookEnabledEvents of this type are ignored.
HookDisabledEvents of this type are ignored.
KeyPressedOnly KeyCode is considered.
KeyReleasedOnly KeyCode is considered.
KeyTyped Events of this type are ignored. PostText(string) should be used to post Unicode characters.
MousePressed Only X, Y, and Button are considered.
MouseReleased Only X, Y, and Button are considered.
MouseClickedEvents of this type are ignored.
MouseMovedOnly X and Y are considered.
MouseDraggedNot recommended to use; same as MouseMoved.
MouseWheel Only Rotation, Direction, and Type are considered.
See Also

PostText(string)

Simulates the input of arbitrary Unicode characters.

UioHookResult PostText(string text)

Parameters

text string

The text to simulate.

Returns

UioHookResult

The result of the operation.

Remarks

The text to simulate doesn't depend on the current keyboard layout. The full range of UTF-16 (including surrogate pairs, e.g. emojis) is supported.

On Windows text simulation should work correctly and consistently.

On macOS applications are not required to process text simulation, but most of them should handle it correctly.

X11 doesn't support text simulation 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. This means that text entry on Linux works slowly and is not guaranteed to be correct. SetPostTextDelayX11(ulong) can be used to increase (or decrease) the delay if needed - longer delays add consistency but may be more jarring to end users. GetPostTextDelayX11() can be used to get the currently configured delay - the default is 50 milliseconds.

See Also

SetPostTextDelayX11(ulong)

Sets the delay (in nanoseconds) between posting individual characters when posting text on Linux.

void SetPostTextDelayX11(ulong delayNanoseconds)

Parameters

delayNanoseconds ulong

The delay (in nanoseconds) between posting individual characters when posting text on Linux.

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 this method does nothing.

See Also

See Also