Register Global HotKey:
1.first to declare the message funciton procedure WMhotKey(var Message: TMessage); message WM_HOTKEY;2.
var
id: ATOM;procedure TForm1.FormCreate(Sender: TObject);
begin
id := GlobalAddAtom('GetScreenColor_HotKey_F12');
if not RegisterHotKey(Form1.Handle, id, 0, $7B) then //Register F12
ShowMessage('Can not Register HotKey!');
end;procedure TForm1.FormDestroy(Sender: TObject);
begin
if not UnregisterHotKey(Form1.Handle, id) then
ShowMessage('Can not Unregister HotKey!');
GlobalDeleteAtom(id);
end;procedure TForm1.WMhotKey(var Message: TMessage);
begin
if HIWORD(Message.lParam) = $7B then
begin
//do what u want
end;
end;
1.first to declare the message funciton procedure WMhotKey(var Message: TMessage); message WM_HOTKEY;2.
var
id: ATOM;procedure TForm1.FormCreate(Sender: TObject);
begin
id := GlobalAddAtom('GetScreenColor_HotKey_F12');
if not RegisterHotKey(Form1.Handle, id, 0, $7B) then //Register F12
ShowMessage('Can not Register HotKey!');
end;procedure TForm1.FormDestroy(Sender: TObject);
begin
if not UnregisterHotKey(Form1.Handle, id) then
ShowMessage('Can not Unregister HotKey!');
GlobalDeleteAtom(id);
end;procedure TForm1.WMhotKey(var Message: TMessage);
begin
if HIWORD(Message.lParam) = $7B then
begin
//do what u want
end;
end;
就是用“&”方式的方法