Delphi 操作键盘按下和释放操作
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}
//======================================================================
Delphi 操作键盘按下和释放操作的更多相关文章
- Delphi的分配及释放---New/Dispose, GetMem/FreeMem及其它函数的区别与相同
转载自:http://www.cnblogs.com/qiusl/p/4028437.html?utm_source=tuicool 我估摸着内存分配+释放是个基础的函数,有些人可能没注意此类函数或细 ...
- delphi.memory.分配及释放---New/Dispose, GetMem/FreeMem及其它函数的区别与相同
我估摸着内存分配+释放是个基础函数,有些人可能没注意此类函数或细究,但我觉得还是弄明白的好. 介绍下面内存函数前,先说一下MM的一些过程,如不关心可忽略: TMemoryManager = recor ...
- Delphi中关于资源释放(Free,Relealse,FreeAndNil)
根据日常编程经验,得出一些Delphi中关于资源释放的体会. 假如有对象Obj为TObject类型: 1) Obj.Free直接释放资源后,调用OnDestroy事件,但是没有将Obj指针值置为Nil ...
- delphi.memory.分配及释放---New/Dispose, GetMem/FreeMem及其它函数的区别与相同,内存分配函数
来自:http://www.cnblogs.com/qiusl/p/4028437.html?utm_source=tuicool&utm_medium=referral ---------- ...
- Delphi关于记录文件的操作
http://www.cnblogs.com/railgunman/archive/2010/08/16/1801004.html Delphi关于记录文件的操作 本例子几个变量的说明TFileR ...
- delphi record 内存怎么释放
delphi record 内存怎么释放 是不需要释放的,除非你使用指针方式生成的.
- using可以用于释放操作,相当于Dispose()
using可以用于释放操作,相当于Dispose()
- Delphi对ini文件的操作
一.INI文件的结构:; 注释[小节名]关键字=值 INI文件允许有多个小节,每个小节又允许有多个关键字, “=”后面是该关键字的值. 值的类型有三种:字符串.整型数值和布尔值.其中字符串存贮在INI ...
- Delphi 的接口机制——接口操作的编译器实现过程(1)
学习COM编程技术也快有半个月了,这期间看了很多资料和别人的程序源码,也尝试了用delphi.C++.C#编写COM程序,个人感觉Delphi是最好上手的.C++的模版生成的代码太过复杂繁琐,大量使用 ...
随机推荐
- 二分法查找 (Binary Search)
二分法查找适用于排列有序的数据.java实现方法如下: // Find the location of a value in array a // Array a must be sorted // ...
- 出现“安全时间戳无效,因为其创建时间(“2013-10-30T14:42:07.861Z”)是将来的时间。当前时间为“2013-10-30T14:36:23.988Z”,允许的时钟偏差是“00:05:00””的原因
具体原因是服务器的时间和本地的时间不能超过5分钟,超过5分钟了.只要修改你本地机器的时间,和服务器相差的时间不能超过5分钟,就可以了. 根本原因是windows 系统域认证要求的,所有都一样.
- R(1):中文乱码解决方案
读取csv文件出现中文乱码方案,增加编码格式参数 read.csv(trainPath,header=TRUE,stringsAsFactors=TRUE,encoding = "UTF-8 ...
- Hbuilder mui 相册拍照图片上传
http://www.bcty365.com/content-146-3648-1.html 使用流程 弹出actionSheet /*点击头像触发*/ document.getElementById ...
- Python网络爬虫-Scrapy框架
一.简介 Spider是所有爬虫的基类,其设计原则只是为了爬取start_url列表中网页,而从爬取到的网页中提取出的url进行继续的爬取工作使用CrawlSpider更合适. 二.使用 1.创建sc ...
- 在HTML标签的事件后面直接写JS代码
<input type="button" onclick="document.getElementdByTagName('div')[0].innrtHTML='S ...
- VBA 对比两行数据
Sub DB_Row() Dim i, j As Integer Dim row1, row2 As Integer row1 = ' 对比第 3 行 row2 = ' 和第 4 行 For i = ...
- 微信jssdk批量添加卡券接口
1)首先是官方接口文档: 1.批量添加卡券接口:https://mp.weixin.qq.com/wiki?action=doc&id=mp1421141115&t=0.0861973 ...
- 从jar包还原出java源码(项目文件)
原文转载至:https://blog.csdn.net/mxmxz/article/details/73043156 上周接到个新任务,一个遗留的接口工程需要改造,然而根据前任开发留下的文档看,这个工 ...
- 高通QMI协议
QMI(Qualcomm MSM Interface,官方名称应该是Qualcomm Message Interface)是高通用来替代OneRPC/DM的协议,用来与modem通信. QMI协议定义 ...