Capture key events from a Windows Service in C#

后端 未结 3 2024
时光取名叫无心
时光取名叫无心 2021-01-22 04:22

I have to write an application in C# that listens to any keys being pressed. In actuality I have a bar code scanner sending the \"key pressed\" event, and I need to listen it..

3条回答
  •  余生分开走
    2021-01-22 04:51

    You will have to learn pInvoke with combination of learning how to look for the right events produced at the lower level of OS. By calling into user32.dll using pInvoke your managed code can filter those events through the hooks.

    http://pinvoke.net/default.aspx/user32.SetWindowsHookEx

提交回复
热议问题