我如何关掉Caps Lock键 [英] How do i Turn OFF the Caps lock key
本文介绍了我如何关掉Caps Lock键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何我关掉大写锁定在文本框键。我使用WPF的形式。
How do i Turn OFF the Caps lock key in textbox. I am using WPF forms.
在文本框的重点是我要关闭大写锁定。
When textbox is focused I want to turn off caps lock.
感谢
推荐答案
它很容易,首先添加命名空间
Its easy , Firstly add namespace
using System.Runtime.InteropServices;
然后在类中声明该
then declare this in the class
[DllImport("user32.dll")]
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags,
UIntPtr dwExtraInfo);
最后,在textBox_Enter事件中添加以下代码
Finally , at textBox_Enter event add this code
private void textBox1_Enter(object sender, EventArgs e)
{
if (Control.IsKeyLocked(Keys.CapsLock)) // Checks Capslock is on
{
const int KEYEVENTF_EXTENDEDKEY = 0x1;
const int KEYEVENTF_KEYUP = 0x2;
keybd_event(0x14, 0x45, KEYEVENTF_EXTENDEDKEY, (UIntPtr)0);
keybd_event(0x14, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,
(UIntPtr)0);
}
}
此代码将关闭大写锁定..我有用它在输入事件时,可以根据您的要求添加!
this code will turn off the Capslock .. I have used it at the enter event you can add it according to your requirement!
结帐这个链接的这里
这篇关于我如何关掉Caps Lock键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文