📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
HotkeyF1,HotKeyF2:integer;
procedure WMHotkeyHandle(var Msg: TMessage); message WM_HOTKEY;
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
{ TForm1 }
//比较两个字符串是否相同
function WooolCompareStr(s1, s2: string): Boolean;
begin
result := False;
if (Length(s1) < 8) or (Length(s2) < 8) then exit; //判断s1,s2长度小于不小于8
result := (s1[1] = s2[1]) and (s1[2] = s2[2]) and (s1[3] = s2[3]) and (s1[4] = s2[4]) and
(s1[5] = s2[5]) and (s1[6] = s2[6]) and (s1[7] = s2[7]) and (s1[8] = s2[8]);
end;
{ TForm1 }
procedure TForm1.WMHotkeyHandle(var Msg: TMessage);
var
hwnd:THandle;
begin
hWnd := getforegroundwindow;
if Msg.WParam=HotkeyF1 then
ShowMessage('alt+F1');
if Msg.WParam=HotkeyF2 then
//ShowMessage('ctrl+q');
Form2.Show;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
HotKeyF1:=GlobalAddAtom(pchar('UserDefinsHotKey1'))-$C000;
RegisterHotKey(Form1.Handle,HotKeyF1,MOD_ALT ,VK_F1); //alt+F1
HotkeyF2:=GlobalAddAtom(pchar('UserDefinsHotKey2'))-$C000;
RegisterHotKey(Form1.Handle,HotkeyF2, MOD_CONTROL ,ord('Q')); //ctrl+q
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
UnregisterHotKey(Form1.Handle,1);
DeleteAtom(HotkeyF1);
DeleteAtom(HotkeyF2);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -