📄 unitfrmmain.pas
字号:
unit unitFrmMain;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
AppEvnts;
type
TForm1 = class(TForm)
ApplicationEvents1: TApplicationEvents;
procedure ApplicationEvents1Idle(Sender: TObject; var Done: Boolean);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
//声明响应WM_HOTKEY消息的方法
procedure WMHotKey(var Msg: TWMHotKey); message WM_HOTKEY;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
const id_SnapShot = 115; //定义热键标识符
{$R *.DFM}
procedure TForm1.ApplicationEvents1Idle(Sender: TObject;
var Done: Boolean);
begin
if GetAsyncKeyState(VK_SNAPSHOT) <> 0 then
Form1.Caption := '已经按下PrintScreen键';
Done := True;
end;
procedure TForm1.WMHotKey(var Msg: TWMHotKey);
begin
if Msg.HotKey = id_SnapShot then
ShowMessage('已经按下PrintScreen键');
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
RegisterHotKey(Form1.Handle, id_SnapShot, 0, VK_SNAPSHOT); //定义热键
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
UnRegisterHotKey(Form1.Handle, id_SnapShot); //释放已经登记的热键
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -