Giter Club home page Giter Club logo

inputhelper's Introduction

InputHelper

Downloads License

A .NET friendly library for handling, simulating and intercepting mouse and keyboard input.

Requirements

  • Windows 7 SP1 or newer (may work on XP/Vista as well, but this has not been tested)
  • .NET Framework: 3.5 / 4.0-4.8, or:
  • .NET Core (Desktop Runtime): 3.1 / 5.0 / 6.0 / 7.0 / 8.0

Precompiled download

A precompiled version of the library (DLL) can be found in the Releases section of this repository.

Documentation

See the project's Wiki page.

Questions, Feature requests, Bug reports, etc.

Have any questions, need help with your code, want to report a bug or simply suggest a new feature?
Feel free to write a ticket on the Issue tracker and I'll get back to you as soon as I can!

inputhelper's People

Contributors

visual-vincent avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

inputhelper's Issues

Window message-based keyboard input interferes with physical key states and sometimes the mouse cursor

While sending Windows Messages to a certain key (Example S) it sometimes keeps any other keys which were held at the time to stay in a held down state.

I also noticed when making a call like:
If InputHelper.Keyboard.IsKeyDown(Keys.S) AndAlso InputHelper.Keyboard.IsKeyDown(Keys.LButton) Then InputHelper.WindowMessages.SendKeyPress(Keys.A) End If
it would sometimes randomly move my cursor, it doesn't always happen, just thought i'd point it out in case the issue was unknown.
(The two issues above happened in the 3.5 version and 4.0)

Lastly, this part isn't a bug, just a suggestion.
Instead of making a 4.x and a 3.5 version you could just create the .Clear StringBuilder extension in a module which would be compatible with both versions.
Example:
Imports System.Runtime.CompilerServices Imports System.Text Module Extensions <Extension()> Public Sub Clear(value As StringBuilder) value.Length = 0 value.Capacity = 0 End Sub End Module

Hooks aren't disposed together with the form they're in

When instantiating a hook in a form the hook is not disposed together with the form when the form is closed.

Steps to reproduce

  1. Create two forms.
  2. Make one form open the other (for instance via a button click).
  3. Put a keyboard and/or mouse hook in the second form.
  4. Use the mouse/keyboard hook.
  5. Close the second form.
  6. Try to use the mouse/keyboard hook again.
  7. It still works!

Code

Form1:

Public Class Form1

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Using form2 As New Form2
            form2.ShowDialog()
        End Using
    End Sub
End Class

Form2:

Public Class Form2

    Dim KeyboardHook As New InputHelper.Hooks.KeyboardHook

    Private Sub Form2_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        AddHandler KeyboardHook.KeyDown, AddressOf KeyboardHook_KeyDown
    End Sub

    Private Sub KeyboardHook_KeyDown(sender As Object, e As InputHelper.EventArgs.KeyboardHookEventArgs)
        If e.Modifiers = (InputHelper.ModifierKeys.Control Or InputHelper.ModifierKeys.Shift) AndAlso e.KeyCode = Keys.E Then
            Debug.WriteLine("'CTRL + SHIFT + E' pressed at " & DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
        End If
    End Sub
End Class

Result

(Immediate Window, Visual Studio)

(Form2 opened by Form1)
(User presses CTRL + SHIFT + E)

'CTRL + SHIFT + E' pressed at 2019-08-17 02:26:49

(Form2 closed)
(User presses CTRL + SHIFT + E again)

'CTRL + SHIFT + E' pressed at 2019-08-17 02:27:03

Key capture occurs after PowerPoint dealt with the keystrokes

Is there a way to have the hook called before that PowerPoint receives the event?
The goal here would be to use your (great) library to create custom keyboard shortcuts from a VSTO addin.
However, currently, when using a LocalKeyboardHook to capture the event CTRL + SHIFT + C, for instance, then PowerPoint's standard feature for "copy format" still occur before my addin deal (and tries to block) the event.

Touchscreen Mouse Events Not Captured

I am finding that mouse events are triggered OK when using a physical mouse, however when using a touch screen in certain applications, Chrome and Edge so far tested, no mouse events are getting triggered.

Also the Mouse Move event does not trigger in Adobe Acrobat when scrolling a PDF, but click events do trigger OK.

This only happens when using a touch screen.

As soon as the mouse is outside of chrome or edge then the mouse events start triggering again.

I did find someone else is having the issue with low level mouse hooks, but not this code, so it maybe a general limitation

https://stackoverflow.com/questions/50407901/capturing-touch-events-with-lowlevelmouseproc-does-not-work-for-all-applications

Any help would be appreciated, thanks

Could there be actions that "unhook" a local hook?

Hello Vincent,

I hope that you are doing well!

Quick question: are there events or actions that could "unhook" a keyboard local hook? And is there a way to track a local keyboard hook's status?

While I'm still struggling to reproduce this, I ended up several times with the local keyboard hook not working anymore while I was using PPT for regular work. I found out that disposing of the local keyboard hook, and then recreating it, allows to make it work again. But I did not manage (yet) to understand what made the previous local keyboard hook not work anymore, and I would be curious to know what happened and how I can investigate.

Best,

JB

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.