当前位置:网站首页>界面仅允许扫码枪录入禁止手工键盘输入
界面仅允许扫码枪录入禁止手工键盘输入
2022-08-03 05:27:00 【谷凯Jump】
由于扫码枪和键盘都属于外设,对于应用程序来说,无法判断输入源。
可间接的通过按键时间来判断。
扫码枪速度大概在0-50ms之间,平均在8ms左右,手动输入在100-200之间,除非特地快速输入可达到30几ms。
我们取个适中的时间:50ms
DateTime dStart;
DateTime dEnd;
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
dStart = DateTime.Now;
}
private void textBox1_KeyUp(object sender, KeyEventArgs e)
{
dEnd = DateTime.Now;
if ((dEnd - dStart).TotalMilliseconds > 50) { textBox1.Clear(); }
}边栏推荐
猜你喜欢
随机推荐
cobalt strike 的基础使用
go test执行多个文件夹下相同目录的用例
Automatic ticket issuance based on direct reduction of China Southern Airlines app
权限管理 UGO 、 ACL 、特殊权限
2021-06-14
数组与字符串8-最长回文子串
各种cms getshell技巧
window下VS2022封装静态库以及调用静态库
二分查找2 - x的平方根
Difference between @JsonProperty and JSONField?
How the world's leading medical technology company maximizes design productivity | SOLIDWORKS Product Exploration
数组与字符串13-两数之和等于目标数
restful 常用状态码
contos安装php-ffmpeg和tp5.1使用插件
ZEMAX | 如何使用ZOS-API创建自定义操作数
域名管理常见问题:IP、域名和DNS之间的区别和关系
window下VS2022封装动态库以及调用动态库
大佬!Maya+ZBrush+Substance制作泰坦野兽全流程!
ARP协议及简单路由器原理(1)
IP数据包的格式(1)









