empiree / deftsharp.windows.input Goto Github PK
View Code? Open in Web Editor NEWAn open-source .NET library designed for keyboard and mouse control in Windows.
License: MIT License
An open-source .NET library designed for keyboard and mouse control in Windows.
License: MIT License
It would be great to improve the KeyboardManipulator class, and add the ability to press any button you want.
For example:
var keyboardManipulator = new KeyboardManipulator()
keyboardManipulator.Press(Key.A);
This can be very useful in some usage scenarios.
Write KeyboardListener tests for:
Place it in the DeftSharp.Windows.Input.Tests.Keyboard namespace.
Please maintain consistency and pay attention to the code-style of other tests. But at the same time, don't hesitate to try something new.
This task is part of the larger Create API documentation task.
Help from newcomers is welcome!
While solving this task, you can familiarize yourself with the library functionality and help other users to work with it.
To create documentation, please pay attention to the README file. The documentation should be designed in this style, and fully disclose all the features of the MouseListener class. If you have any ideas for new features of this class while writing documentation, please create a new issue and describe your idea.
Place the documentation in the Documentation.md file!
If you have any questions, feel free to post them here! Our project is beginner friendly!
Unsubscribe()
method to unsubscribe from multiple keys.In the KeyboardListener class we have convenient methods for unsubscribing by key, but nothing for unsubscribing from multiple related keys. For example, for combinations of.
I would like to implement an Unsubscribe()
method overload that supports this. But we need to do it in a way that is convenient and doesn't confuse people. Because we can have a collection of single keys as well as collections of combinations and sequences.
There is an option, but I think we can come up with a better solution.
var keyboardListener = new KeyboardListener();
Key[] keys = [Key.LeftCtrl, Key.V];
keyboardListener.SubscribeCombination(keys, _ => { });
keyboardListener.Unsubscribe(keys, UnsubscribeOption.Combination);
You can help with creating documentation.
Write KeyboardListener tests for:
Place it in the DeftSharp.Windows.Input.Tests.Keyboard namespace.
Please maintain consistency and pay attention to the code-style of other tests. But at the same time, don't hesitate to try something new.
Write KeyboardBinder tests in the DeftSharp.Windows.Input.Tests.Keyboard namespace. Feel free to try something new, you don't have to do everything according to other tests. But if you don't have any ideas, you can look at how other tests are implemented.
I would like to discuss one of the ideas for future releases.
This idea consists in creating a custom interceptor, the logic of which can be described in a class, for example, inheriting from CustomKeyboardInterceptor
.
The logic is as follows: before any button press is processed, we pass through registered interceptors such as KeyboardListener, KeyboardManipulator, etc. If at least 1 interceptor does not allow processing of the press, it will not be processed anywhere and the OnPipelineFailed method will be called, if all interceptors allow processing of the key, the OnPipelineSuccess method will be called.
So, I'm thinking of making it possible for the user to create custom interceptors that will be registered with all other interceptors in one pipeline. This would allow the user to decide and define the processing logic. But this way is a bit more complicated than usual, so I want to focus on convenient methods, and leave this option as the last one.
Here is an example of one such class:
How do you feel about that?
This task is part of the larger Create API documentation task.
Help from newcomers is welcome!
While solving this task, you can familiarize yourself with the library functionality and help other users to work with it.
To create documentation, please pay attention to the README file. The documentation should be designed in this style, and fully disclose all the features of the KeyboardListener class. If you have any ideas for new features of this class while writing documentation, please create a new issue and describe your idea.
Place the documentation in the Documentation.md file!
If you have any questions, feel free to post them here! Our project is beginner friendly!
I propose to create a small method that will change button bindings between each other.
keyboardBinder.Swap(Key.Q, Key.W)
Instead of
keyboardBinder.Bind(Key.Q, Key.W);
keyboardBinder.Bind(Key.W, Key.Q);
But you need to consider the fact that one of these buttons may already be with a different bind. We need to think about what behavior is needed in such a scenario.
Write KeyboardManipulator tests for:
Place it in the DeftSharp.Windows.Input.Tests.Keyboard namespace.
Please maintain consistency and pay attention to the code-style of other tests. But at the same time, don't hesitate to try something new.
My suggestion is to make it so that the user specifies the time needed to trigger an event when a certain key is held down. This could be very useful.
Example:
var keyboardListener = new KeyboardListener();
keyboardListener.SubscribePress(Key.A, key => {
// logic
}, TimeSpan.FromSeconds(2)); // time for trigger
Add the ability to have the event handler trigger after a certain time after the button is clicked. For example, after 5 seconds.
keyboardListener.Subscribe(Key.A, key =>
{
// do smth after 5 seconds...
}).WithDelay(TimeSpan.FromSeconds(5));
Currently, the NumpadListener class only takes one Action<Key>
argument when subscribing. It would be great to extend its functionality, and add optional parameters that exist in the Subscribe()
methods in the KeyboardListener class.
TimeSpan
parameter that will accept the delegate trigger interval.KeyboardEvent
parameter that will accept the event type.Also, you can think how to improve this class. Feel free to suggest your ideas!
I will be glad to answer all your questions!
NumpadListener is a decorator over the KeyboardListener class, it allows you to subscribe to the presses of the numeric buttons on the NumPad in a convenient way.
At the moment, when the Unsubscribe()
method of NumpadListener is called, it unsubscribes from all Numpad events registered in KeyboardListener, even those created directly through KeyboardListener.
Therefore, the proposed solution is to make the NumpadListener unsubscribe only from those events that were created exclusively by it. This can be achieved by using GUID unsubscription.
Important! The Subscribe()
method in NumpadListener can be called several times and more subscriptions will be created.
If there are any questions, feel free to ask! Help from newcomers is welcome!
Write MouseManipulator tests in the DeftSharp.Windows.Input.Tests.Mouse namespace.
Please maintain consistency and pay attention to the code-style of other tests. But at the same time, don't hesitate to try something new.
1. Implement the ability to set the sequence of keystrokes as a condition for triggering an event.
For example:
var sequence = new ButtonSequence(Key.A, Key.B);
keyboardListener.SubscribeSequence(sequence, e => {
// do smth...
})
2. Implement the ability to set a combination of keystrokes as a condition for triggering an event..
For example:
var combination = new ButtonCombination(Key.A, Key.B);
keyboardListener.SubscribeCombination(combination, e => {
// do smth...
})
In release 0.5, we added a new feature of pressing key combinations using KeyboardManipulator
. But some system combinations don't work for some reason.
Our goal is to find all the combinations that don't work and find out what the problem is.
Please post here all combinations that didn't work for you.
There is code duplication in the project with the definition of sets of keyboard keys (for example, a collection of numpad buttons for NumpadListener
class and for tests NumpadListenerSubscribeTests
and NumpadListenerUnsubscribeTests
).
The proposed solution is to make a KeyboardKeySet
class that will provide collections of specific keyboard keys (numpad keys, number keys, function keys, etc.).
Advantages:
Proposed key sets:
This would allow many more users to be reached
This class will handle pressing any digits on the keyboard. Follow the NumpadListener example.
The class must contain a Subscribe
method that will accept Action<Key>
and will subscribe to all possible number buttons, including NumPad.
And it must also contain an Unsubscribe
method to unsubscribe from all keyboard events.
Important! Use GUID
to unsubscribe only those subscriptions that we have created inside this class.
The 0.6 update introduced custom interceptors. It would be great to write a couple of small tests that will check their performance.
Place it in the DeftSharp.Windows.Input.Tests.CustomInterceptors namespace.
Please maintain consistency and pay attention to the code-style of other tests. But at the same time, don't hesitate to try something new.
There are no requirements as such, it all depends on your imagination. If you have any questions, I will be happy to answer them :)
This class will handle pressing any letters on the keyboard. Follow the NumpadListener example.
The class must contain a Subscribe
method that will accept Action<Key>
and will subscribe to all possible letter buttons.
And it must also contain an Unsubscribe
method to unsubscribe from all keyboard events.
Important! Use GUID
to unsubscribe only those subscriptions that we have created inside this class.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.