将System.Windows.Forms.Keys的序列转换为Char [英] Convert sequence of System.Windows.Forms.Keys to a Char
问题描述
是否有一种方法可以转换由键枚举表示的一系列击键(即 System.Windows.Forms.Keys
)。例如: Keys.Oem4
,然后 Keys.A
产生char á
。它必须存在于WinAPI的某个地方,因为Windows为我做这个,当我按下文本框中的键...我只是不知道在哪里。请帮忙!感谢。
Is there a way to convert a sequence of keystrokes represented by the Keys enum (i.e. System.Windows.Forms.Keys
) in a Char. For example: Keys.Oem4
and then Keys.A
yields the char á
. It must exist somewhere in the WinAPI, because Windows does that for me, when I press keys inside a text-box... I just don't know where. Please help! thanks.
编辑:
我想要的是记录用户输入
What I want is to record the user input keys, and later translate the sequence of keys to characters, without the user having to type everything again, something like a macro.
推荐答案
最简单的方法是首先将 Key
值转换为虚拟键代码。这是通过 KeyInterop.VirtualKeyFromKey 。然后,您可以将PInvoke导入到 MapVirtualKey 功能中将密钥转换为char。
The most straight forward way to do this is to first convent the Key
value into a Virtual Key code. This is done via KeyInterop.VirtualKeyFromKey. You can then PInvoke into the MapVirtualKey function to convert the key into a char.
这篇关于将System.Windows.Forms.Keys的序列转换为Char的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!