C#检查键盘大小写锁定状态的方法
作者:欧阳不疯 时间:2022-01-11 18:00:39
本文实例讲述了C#检查键盘大小写锁定状态的方法。分享给大家供大家参考。具体分析如下:
1、命名空间:
using System.Runtime.InteropServices;
2、导入方法
[DllImport("user32.dll", EntryPoint = "GetKeyboardState")]
public static extern int GetKeyboardState(byte[] pbKeyState);
3、大小写状态
public static bool CapsLockStatus
{
get
{
byte[] bs = new byte[256];
GetKeyboardState(bs);
return (bs[0x14] == 1);
}
}
4、引用,此部分根据你的需要来修改
private void button2_Click(object sender, EventArgs e)
{
if (CapsLockStatus == true)
MessageBox.Show("键盘处于大写锁定状态!");
else
MessageBox.Show("键盘处于小写状态!");
}
希望本文所述对大家的C#程序设计有所帮助。
标签:C#,键盘
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Java中通过Class类获取Class对象的方法详解
2021-11-09 17:12:57
Java如何提供给第三方使用接口方法详解
2022-07-22 19:59:19
Java泛型通配符的使用详解
2022-07-08 14:08:43
SpringMVC中@ModelAttribute与@RequestBody的区别及说明
2023-11-24 12:09:51
![](https://img.aspxhome.com/file/2023/7/59747_0s.png)
SpringBoot 上传文件判空以及格式检验流程
2023-01-19 05:07:36
![](https://img.aspxhome.com/file/2023/5/61405_0s.png)
Java Swing实现扫雷源码
2023-11-10 08:16:20
![](https://img.aspxhome.com/file/2023/9/59069_0s.jpg)
C#中WebClient实现文件下载
2022-10-11 18:04:57
![](https://img.aspxhome.com/file/2023/5/77275_0s.png)
Java SpringBoot高级用法详解
2021-07-03 18:27:09
![](https://img.aspxhome.com/file/2023/8/62998_0s.png)
intellij idea14打包apk文件和查看sha1值
2022-05-25 13:18:37
![](https://img.aspxhome.com/file/2023/6/91746_0s.jpg)
浅谈Java中向上造型向下造型和接口回调中的问题
2023-11-09 13:51:46
![](https://img.aspxhome.com/file/2023/1/59151_0s.jpg)
详解jvm对象的创建和分配
2022-01-27 13:39:41
![](https://img.aspxhome.com/file/2023/0/75800_0s.png)
JSON复杂数据处理之Json树形结构数据转Java对象并存储到数据库的实现
2023-09-17 17:03:59
Java抽象类与接口区别详解
2021-06-19 19:22:37
![](https://img.aspxhome.com/file/2023/5/76265_0s.png)
Java多线程的用法详解
2021-10-29 19:20:59
使用SpringBoot开发Restful服务实现增删改查功能
2023-01-20 05:17:29
![](https://img.aspxhome.com/file/2023/8/61658_0s.png)
spring中的BeanFactory与FactoryBean的讲解
2023-03-13 11:18:09
![](https://img.aspxhome.com/file/2023/3/66053_0s.png)
C#开发教程之利用特性自定义数据导出到Excel
2023-03-02 22:55:42
![](https://img.aspxhome.com/file/2023/1/82231_0s.png)
C#操作XML方法详解
2022-11-10 21:21:14
java集合继承关系图分享
2023-04-25 17:17:23
![](https://img.aspxhome.com/file/2023/0/67480_0s.png)
java 实现MD5加密算法的简单实例
2023-07-19 21:53:56