Delphi 操作键盘按下和释放操作
2024-08-28 20:05:35
Unit Unit1; Interface Uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls; Type
TForm1 = Class(TForm)
ReleaseScrollLockBtn: TButton;
SetScrollLockBtn: TButton;
Procedure SetScrollLockBtnClick(Sender: TObject);
Procedure ReleaseScrollLockBtnClick(Sender: TObject);
Private
{ Private declarations }
Public
{ Public declarations }
End; Var
Form1 : TForm1; Implementation {$R *.DFM} //----------------------------------------------------------------------
// The Numlock key can be pressed this way under NT but NOT under W95!
// The ScrollLock and CapsLock can be pressed this way under NT and W95
// as well.
// You can also simulate a PrintScreen (SnapShot).
// See the Delphi help file for soft-pressing this key.
// (Set the blinking cursor in the word: "keybd_event" and press: "F1")
//----------------------------------------------------------------------
Procedure SetNumLock(Bo : Boolean); Var
keyState : TKeyBoardState; Begin
GetKeyboardstate(keyState);
// keyState[VK_SCROLL] = 0 means the led is off
// keyState[VK_SCROLL] 0 means the led is on
If ( (Bo = True) and (keyState[VK_SCROLL] = ) ) or
( (Bo = False) and (keyState[VK_SCROLL] ) ) then
Begin
// Simulate a depress
keybd_event(VK_SCROLL,,KEYEVENTF_EXTENDEDKEY,);
// Simulate a release
keybd_event(VK_SCROLL,,KEYEVENTF_EXTENDEDKEY + KEYEVENTF_KEYUP,);
End;
End;
//----------------------------------------------------------------------
Procedure TForm1.SetScrollLockBtnClick(Sender: TObject); Begin
SetNumLock(TRUE);
End;
//----------------------------------------------------------------------
Procedure TForm1.ReleaseScrollLockBtnClick(Sender: TObject); Begin
SetNumLock(FALSE);
End;
//----------------------------------------------------------------------
End. {of Unit1}
//======================================================================
最新文章
- JSON金额解析BUG的解决过程
- Web3DGame之路(三)分析babylonjs
- Wix 安装部署(一)同MSBuild 自动生成打包文件
- java utf-8文件处理bom头
- 第十五章:Android 调用WebService(.net平台)
- uml中定义的关系详细详解
- curl get started
- 还在在专业的blog记录生活吧!
- 关于Tcp三次握手的思考
- [React] Styling a React button component with Radium
- USB OTG简要
- SSE图像算法优化系列十:简单的一个肤色检测算法的SSE优化。
- 防止html5的video标签在iphone中自动全屏
- EF架构~Dapper.Contrib不能将Linq翻译好发到数据库,所以请不要用它
- asp 获取url 返回值 和 对json 返回值的处理
- LoadRunner简单介绍----性能自动化测试工具
- LNMP平台部署
- linux log
- TCP加速锐速SS(ServerSpeeder)破解版一键安装
- kubernetes下安装mysql
热门文章
- Microsoft Dynamics CRM 2011 中 SQL 语句总结
- CentOS7 安装mysql(YUM方式)
- 胖子哥的大数据之路(6)- NoSQL生态圈全景介绍
- ALGO-2_蓝桥杯_算法训练_最大最小公倍数
- python学习笔记--smtp模块的使用及常见错误处理
- 微信小程序之for循环
- Spring IOC - 控制反转(依赖注入) - 创建对象的方式
- java.lang.Object类
- 长沙雅礼中学集训-------------------day1(内含day0)
- 学习MongoDB 五: MongoDB查询(数组、内嵌文档)(二)