本文介绍了如何确定"capsLock"?在吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发打字导师....
在此项目中,要确定"capsLock"是否在...上.
请帮助我..
I am developing a typing tutor....
In this project a want to determine that "capsLock" is on .....
please help me..
推荐答案
bool isCapsLockOn = Control.IsKeyLocked(Keys.CapsLock);
有关 MSDN:Control.IsKeyLocked方法 [ ^ ].
问候,
Manfred
Details on MSDN: Control.IsKeyLocked Method [^].
Regards,
Manfred
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
public class CapsLockControl
{
[DllImport("user32.dll")]
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags,UIntPtr dwExtraInfo);
const int KEYEVENTF_EXTENDEDKEY = 0x1;
const int KEYEVENTF_KEYUP = 0x2;
public static void Main()
{
if (Control.IsKeyLocked(Keys.CapsLock))
{
Console.WriteLine("Caps Lock key is ON. We'll turn it off");
keybd_event(0x14, 0x45, KEYEVENTF_EXTENDEDKEY, (UIntPtr) 0);
keybd_event(0x14, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,
(UIntPtr) 0);
}
else
{
Console.WriteLine("Caps Lock key is OFF");
}
}
}
或在此处 [ ^ ]
在此处找到此解决方案: http://cboard.cprogramming.com/csharp-编程/105103-how-detect-capslock-csharp.html [ ^ ].
or look here[^]
This solution was found here: http://cboard.cprogramming.com/csharp-programming/105103-how-detect-capslock-csharp.html[^].
这篇关于如何确定"capsLock"?在吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!