SilvanBauer.InputActions
1.0.1
See the version list below for details.
dotnet add package SilvanBauer.InputActions --version 1.0.1
NuGet\Install-Package SilvanBauer.InputActions -Version 1.0.1
<PackageReference Include="SilvanBauer.InputActions" Version="1.0.1" />
paket add SilvanBauer.InputActions --version 1.0.1
#r "nuget: SilvanBauer.InputActions, 1.0.1"
// Install SilvanBauer.InputActions as a Cake Addin #addin nuget:?package=SilvanBauer.InputActions&version=1.0.1 // Install SilvanBauer.InputActions as a Cake Tool #tool nuget:?package=SilvanBauer.InputActions&version=1.0.1
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. Additionally the Input Actions library also provides support for capturing xbox controller inputs.
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);
}
XInputController (Xbox Controllers)
The XInputController
is a class which can be instantiated and with the Update
method the current controller state of the first connected controller will be set in the XInputController
instance.
Links
Product | Versions 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. |
-
.NETStandard 2.1
- Microsoft.CSharp (>= 4.7.0)
- SharpDX.XInput (>= 4.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Added methods for getting and manipulating keys