我如何捕获keydown值. [英] How can i capture keydown value .
问题描述
我已经创建了一个Windows应用程序,可以捕获keydown或keypress值.
它有一个局限性,即当我在Windows应用程序中按下或按下按键时,它可以捕获按键按下值.
但是,当我在记事本或其他应用程序中按下键盘时,则无法捕获按下键盘的值.
我想在任何地方捕获任何keydown值.
例如.我在记事本中键入内容,那么那时我的应用程序还将捕获我在notepade中键入内容的keydown值.
I have create a windows application that can capture the keydown or keypress value.
It has a limitation that is when I Keypress or keydown within a windows application then it can capture keydown value.
However, when I keydown in notepad or some other application then it cannot capture keydown value.
I want to capture any keydown value any where.
Eg. I am typing in notepad then that time my application will also capture that keydown value of what I am typing in the notepade.
Please anyone help me as I am new to C#.
推荐答案
KeyDown
(和KeyPress
)事件仅用于实现这些事件的控件,请有人帮我.上.这些将不适用于任何其他控件或程序.
TheKeyDown
(andKeyPress
) events are only for the control that you have implemented these events on. These will not work for any other control or program.
您可以使用键盘挂钩(通过Windows API使用非常复杂的技术),例如:
- MSDN上的挂钩概述 [如何在C#中设置低级鼠标钩和键盘钩? [ ^ ].
- 低C#中的高级键盘钩 [ ^ ].
You may use a keyboard hook (quite complex technique, via Windows API) see, for instance:
- Hooks Overview at MSDN[^].
- How do I set a low level mouse hook and keyboard hook in C#?[^].
- Low-Level Keyboard Hook in C#[^].
这篇关于我如何捕获keydown值.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!