Empiree / DeftSharp.Windows.Input

An open-source .NET library designed for keyboard and mouse control in Windows.
MIT License
73 stars 21 forks source link

Custom Interceptors #30

Closed Empiree closed 8 months ago

Empiree commented 8 months ago

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:

image

How do you feel about that?

Empiree commented 8 months ago

An example of a simple keyboard logger.

image

nullptrException100 commented 8 months ago

Yes, it looks very useful in certain scenarios. Ideally, make 95% of all needs covered by already written interceptors, like KeyboardListener. But in the case where that's not enough, this way could make it much easier to implement.

I support this idea.

Empiree commented 8 months ago

Added in 0.6 release! Changelog

AlexanderBlackman commented 8 months ago

Added in 0.6 release! Changelog

Excellent! You solve problems so quickly.