SilvanBauer.InputActions 1.0.2

dotnet add package SilvanBauer.InputActions --version 1.0.2
NuGet\Install-Package SilvanBauer.InputActions -Version 1.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SilvanBauer.InputActions" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SilvanBauer.InputActions --version 1.0.2
#r "nuget: SilvanBauer.InputActions, 1.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SilvanBauer.InputActions as a Cake Addin
#addin nuget:?package=SilvanBauer.InputActions&version=1.0.2

// Install SilvanBauer.InputActions as a Cake Tool
#tool nuget:?package=SilvanBauer.InputActions&version=1.0.2

InputActions

A small class library which provides classes with methods to capture user inputs with hooks and to simulate user actions. This is made possible by using the user32.dll.

This library was created to provide an easy to use solution for capturing and making user inputs with the keyboard or the mouse.

Classes and Methods

MouseActions

MouseActions is the static class providing user input and output methods for mouse actions.

  • bool SetMousePosition(int x, int y)
  • Win32Point GetMousePosition()
  • void RightClick(int x, int y)
  • void RightDown(int x, int y)
  • void RightUp(int x, int y)
  • void MiddleClick(int x, int y)
  • void MiddleDown(int x, int y)
  • void MiddleUp(int x, int y)
  • void LeftClick(int x, int y)
  • void LeftDown(int x, int y)
  • void LeftUp(int x, int y)
  • void ScrollVerticalWheel(int x, int y, int amount)
  • void ScrollHorizonalWheel(int x, int y, int amount)
  • void AddMouseHookAction(MouseHookAction mouseHookAction)
  • void RemoveMouseHookAction(string key)
  • void UnhookMouseHook()

KeyboardActions

KeyboardActions is the static class providing user input and output methods for keyboard actions.

  • KeyState GetKey(KeyboardKey key)
  • void KeyPress(KeyboardKey key)
  • void KeyUp(KeyboardKey key)
  • void KeyDown(KeyboardKey key)
  • void AddKeyboardHookAction(KeyboardHookAction keyboardHookAction)
  • void RemoveKeyboardHookAction(string key)
  • void UnhookKeyboardHook()

Hooks

When a add hook method is used a windows hook is created and the hook action is added. With the add command the same hook will have another action registered instead of creating another hook. With the remove method a registered hook action can be removed. If the last one was removed then the hook will be unhooked. To unhook all hooks at once there is the unhook methods.

KeyboardActions.AddKeyboardHookAction(new KeyboardHookAction() {
    Key = "Test",
    Action = TestKeyboardHookAction,
    KeyboardEvent = KeyboardEvent.KeyDown
});
MouseActions.AddMouseHookAction(new MouseHookAction() {
    Key = "Test",
    Action = TestMouseHookAction
});
private void TestKeyboardHookAction(int keyCode) {
    var keyName = Enum.GetName(typeof(KeyboardKey), keyCode);
    var keyState = Enum.GetName(typeof(KeyState), KeyboardActions.GetKey(KeyboardKey.LShift));

    Trace.WriteLine(keyName != null ? keyName : keyCode.ToString());
    Trace.WriteLine(keyState);
}
private void TestMouseHookAction(int mouseAction) {
    var mouseActionName = Enum.GetName(typeof(MouseEvent), mouseAction);
    Trace.WriteLine(mouseActionName);

    KeyboardActions.KeyDown(KeyboardKey.LShift);
    KeyboardActions.KeyPress(KeyboardKey.A);
    KeyboardActions.KeyPress(KeyboardKey.B);
    KeyboardActions.KeyPress(KeyboardKey.C);
    KeyboardActions.KeyUp(KeyboardKey.LShift);
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.2 136 10/7/2023
1.0.1 414 10/20/2022
1.0.0 395 10/19/2022

Removed XBox controller support because of additional packages