Caps Lock判断
如何判断是否按下大小写键,如果当前是小写,按下Caps Lock 则提示大写字母打开,否则提示小写字母打开
程序代码:using System;
using System.Runtime.InteropServices;
namespace testdatetostr
{
class Program
{
[DllImport("USER32", SetLastError = true)]
static extern short GetKeyState(int nVirtKey);
static void Main(string[] args)
{
Console.WriteLine(GetKeyState(20) == 1 ? "大写字母打开" : "小写字母打开");
Console.ReadKey();
}
}
}