|
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
Vcl.StdCtrls, Vcl.ComCtrls;
type
TForm1 = class(TForm)
RichEdit1: TRichEdit;
procedure FormCreate(Sender: TObject);
procedure hotykey(var msg: TMessage); message WM_HOTKEY;
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
id1, id2, id3, id4: Integer; //id1 ctrl+shift+v , id2 ctrl+shift+window+v
implementation
{$R *.dfm}
procedure TForm1.FormDestroy(Sender: TObject);
begin
UnRegisterHotKey(handle, id1); //ctrl+shift+V
UnRegisterHotKey(handle, id2); //ctrl+shift+window+V
UnRegisterHotKey(handle, id3); //ctrl+shift+Alt+Window+V
UnRegisterHotKey(handle, id4); //Window+S
end;
procedure TForm1.hotykey(var msg: TMessage); //定义下面这种热键,要先写长的判断,不然没有反应!这就是原因!
begin
if (GetAsyncKeyState(VK_CONTROL) < 0) and (GetAsyncKeyState(VK_SHIFT) < 0) and (GetAsyncKeyState(VK_MENU) and (GetAsyncKeyState(VK_LWIN) and (GetAsyncKeyState(Ord('V')))) < 0) then //Ctrl+Shift+Alt+Window+V
ShowMessage('Ctrl+Shift+Alt+Window+V');
if (GetAsyncKeyState(VK_CONTROL) < 0) and (GetAsyncKeyState(VK_SHIFT) < 0) and (GetAsyncKeyState(VK_LWIN) and (GetAsyncKeyState(Ord('V'))) < 0) then //Ctrl+Shift+Window+V
ShowMessage('Ctrl+Shift+Window+V');
if (GetAsyncKeyState(VK_LWIN) and (GetAsyncKeyState(Ord('S'))) < 0) then //Window+V
ShowMessage('Window+S');
//if (msg.LParamLo = MOD_CONTROL) and (msg.LParamHi = 86) then
if (GetAsyncKeyState(VK_CONTROL) < 0) and (GetAsyncKeyState(VK_SHIFT) < 0) and (GetAsyncKeyState(Ord('V')) < 0) then //ctrl+shift+v
begin
ShowMessage('ctrl+shift+v');
RichEdit1.PasteFromClipboard;
end;
end;
procedure TForm1.FormCreate(Sender: TObject); //另外 hotkey1 hotkey2 hotkey3要写三个
begin
id1 := GlobalAddAtom('hotkey1');
RegisterHotKey(handle, id1, MOD_CONTROL + MOD_SHIFT, 86); //ctrl+shift+V 成功了~~
id2 := GlobalAddAtom('hotkey2');
RegisterHotKey(handle, id2, MOD_CONTROL + MOD_SHIFT + MOD_WIN, 86); //ctrl+shift+window+V 成功了~~
id3 := GlobalAddAtom('hotkey3');
RegisterHotKey(handle, id3, MOD_CONTROL + MOD_SHIFT + MOD_ALT + MOD_WIN, 86); //ctrl+shift+Alt+Window+V 成功了~~
id4 := GlobalAddAtom('hotkey4');
RegisterHotKey(handle, id4, MOD_WIN, 83); //Window+V
end;
end.
|
评分
-
参与人数 6 | HB +1 |
THX +5 |
收起
理由
|
消逝的过去
| |
+ 1 |
|
创客者V2.0
| + 1 |
|
|
zxjzzh
| |
+ 1 |
[吾爱汇编论坛52HB.COM]-学破解防破解,知进攻懂防守! |
agan8888
| |
+ 1 |
|
playboy
| |
+ 1 |
|
vendict
| |
+ 1 |
[快捷评语]--评分=感恩!简单却充满爱!感谢您的作品! |
查看全部评分
|