当前位置: 首页 > news >正文

注册系统级热键

为什么80%的码农都做不了架构师?>>>   hot3.png

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    procedure WMHotKey(var Msg: TWMHotKey); message WM_HOTKEY;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

var
  HotKeyId: array[0..12] of Integer;  //热键数组, 这里准备定义 13 个热键

procedure TForm1.FormCreate(Sender: TObject);
var
  i: Integer;
begin
  //注册热键
  for i := Low(HotKeyId) to High(HotKeyId) do
    HotKeyId[i] := GlobalAddAtom(PChar(IntToStr(i)));  //热键命名可随意
  RegisterHotKey(Handle,HotKeyId[0],0,VK_F2);                //F2
  RegisterHotKey(Handle,HotKeyId[1],0,VK_UP);                //Up
  RegisterHotKey(Handle,HotKeyId[2],0,VK_DOWN);              //Down
  RegisterHotKey(Handle,HotKeyId[3],0,VK_LEFT);              //Left
  RegisterHotKey(Handle,HotKeyId[4],0,VK_RIGHT);             //Right
  RegisterHotKey(Handle,HotKeyId[5],0,VK_PRIOR);             //PageUp
  RegisterHotKey(Handle,HotKeyId[6],0,VK_NEXT);              //PageDown
  RegisterHotKey(Handle,HotKeyId[7],0,VK_OEM_PLUS);          //+
  RegisterHotKey(Handle,HotKeyId[8],0,VK_OEM_MINUS);         //-
  RegisterHotKey(Handle,HotKeyId[9],0,$31);                  //1
  RegisterHotKey(Handle,HotKeyId[10],0,$41);                 //a
  RegisterHotKey(Handle,HotKeyId[11],0,VK_RETURN);           //Enter
  RegisterHotKey(Handle,HotKeyId[12],MOD_CONTROL,VK_RETURN); //Ctrl+Enter
end;

//热键
procedure TForm1.WMHotKey(var Msg: TWMHotKey);
begin
  if Msg.HotKey = HotKeyId[0] then ShowMessage('F2');
  if (Msg.HotKey=HotKeyId[1]) then ShowMessage('Up');
  if (Msg.HotKey=HotKeyId[2]) then ShowMessage('Down');
  if (Msg.HotKey=HotKeyId[3]) then ShowMessage('Left');
  if (Msg.HotKey=HotKeyId[4]) then ShowMessage('Right');
  if Msg.HotKey = HotKeyId[5] then ShowMessage('PageUp');
  if Msg.HotKey = HotKeyId[6] then ShowMessage('PageDown');
  if Msg.HotKey = HotKeyId[7] then ShowMessage('+');
  if Msg.HotKey = HotKeyId[8] then ShowMessage('-');
  if Msg.HotKey = HotKeyId[9] then ShowMessage('1');
  if Msg.HotKey = HotKeyId[10] then ShowMessage('a');
  if Msg.HotKey = HotKeyId[11] then ShowMessage('Enter');
  if Msg.HotKey = HotKeyId[12] then ShowMessage('Ctrl+Enter');
end;

procedure TForm1.FormDestroy(Sender: TObject);
var
  i: Integer;
begin
  //注销热键
  for i := Low(HotKeyId) to High(HotKeyId) do
  begin
    UnRegisterHotKey(handle,HotKeyId[i]);
    GlobalDeleteAtom(HotKeyId[i]);
  end;
end;

end.

 
 
 
 
 

 

 

  

转载于:https://my.oschina.net/hermer/blog/320259

相关文章:

  • .NET Remoting学习笔记(三)信道
  • DHCP服务器的作用
  • 数据库索引的作用和长处缺点
  • Java 将自己定义的对象作为HashMap的key
  • SQL中declare申明变量
  • 常用命令
  • STL之容器适配器queue的实现框架
  • DNS添加/修改/查询/删除A记录
  • 大道至简 电话号码重新成为O2O新宠
  • tomcat日志catalina.out 按天分片分割
  • 【Android-视频播放】实用vitamio自定义控制条位置
  • HBase之MemStore+Flush详解
  • Pair Project 1 elevator
  • DISCUZ 学习笔记四 SEO 设置 板块 分区 导航 模板 修改浏览器标签powerbydis
  • JVM 运行时数据区域
  • 【译】React性能工程(下) -- 深入研究React性能调试
  • C++入门教程(10):for 语句
  • gf框架之分页模块(五) - 自定义分页
  • Go 语言编译器的 //go: 详解
  • JDK9: 集成 Jshell 和 Maven 项目.
  • JS实现简单的MVC模式开发小游戏
  • mac修复ab及siege安装
  • nfs客户端进程变D,延伸linux的lock
  • Spark RDD学习: aggregate函数
  • tensorflow学习笔记3——MNIST应用篇
  • vue和cordova项目整合打包,并实现vue调用android的相机的demo
  • vue--为什么data属性必须是一个函数
  • vue自定义指令实现v-tap插件
  • 机器学习学习笔记一
  • 聊一聊前端的监控
  • 爬虫进阶 -- 神级程序员:让你的爬虫就像人类的用户行为!
  • 前端
  • 入口文件开始,分析Vue源码实现
  • 为物联网而生:高性能时间序列数据库HiTSDB商业化首发!
  • 异步
  • 阿里云移动端播放器高级功能介绍
  • 数据库巡检项
  • ​sqlite3 --- SQLite 数据库 DB-API 2.0 接口模块​
  • ###项目技术发展史
  • #快捷键# 大学四年我常用的软件快捷键大全,教你成为电脑高手!!
  • (6)设计一个TimeMap
  • (Redis使用系列) Springboot 使用Redis+Session实现Session共享 ,简单的单点登录 五
  • (附源码)ssm基于微信小程序的疫苗管理系统 毕业设计 092354
  • (附源码)ssm考试题库管理系统 毕业设计 069043
  • (免费领源码)Python#MySQL图书馆管理系统071718-计算机毕业设计项目选题推荐
  • (亲测有效)解决windows11无法使用1500000波特率的问题
  • (三)c52学习之旅-点亮LED灯
  • (一)kafka实战——kafka源码编译启动
  • (转)Android学习笔记 --- android任务栈和启动模式
  • (转)linux自定义开机启动服务和chkconfig使用方法
  • ***汇编语言 实验16 编写包含多个功能子程序的中断例程
  • .babyk勒索病毒解析:恶意更新如何威胁您的数据安全
  • .bat批处理(四):路径相关%cd%和%~dp0的区别
  • .NET DataGridView数据绑定说明
  • .NET 动态调用WebService + WSE + UsernameToken