程序里使用热键的程序
能提供些这方面的资料更好。
procedure TForm1.hotykey(var msg:TMessage);
begin
if (msg.LParamLo=MOD_CONTROL) and (msg.LParamHi=81) then
begin
ShowMessage(' Ctrl + Q ');
end;if (msg.LParamLo=MOD_CONTROL) and (msg.LParamHi=82) then
begin
ShowMessage(' Ctrl + R ');
end;
end; procedure TForm1.FormCreate(Sender: TObject);
begin
id:=GlobalAddAtom('hotkey');
RegisterHotKey(handle,id,mod_control,81);
id2:=GlobalAddAtom('hotkey2');
RegisterHotKey(handle,id2,mod_control,82);
end;procedure TForm1.FormDestroy(Sender: TObject);
begin
UnRegisterHotKey(handle,id);
UnRegisterHotKey(handle,id2); end;
能提供些这方面的资料更好。
procedure TForm1.hotykey(var msg:TMessage);
begin
if (msg.LParamLo=MOD_CONTROL) and (msg.LParamHi=81) then
begin
ShowMessage(' Ctrl + Q ');
end;if (msg.LParamLo=MOD_CONTROL) and (msg.LParamHi=82) then
begin
ShowMessage(' Ctrl + R ');
end;
end; procedure TForm1.FormCreate(Sender: TObject);
begin
id:=GlobalAddAtom('hotkey');
RegisterHotKey(handle,id,mod_control,81);
id2:=GlobalAddAtom('hotkey2');
RegisterHotKey(handle,id2,mod_control,82);
end;procedure TForm1.FormDestroy(Sender: TObject);
begin
UnRegisterHotKey(handle,id);
UnRegisterHotKey(handle,id2); end;
将Windows的Hot Key转换成字符串
function ShortCutToString(const HotKey:word):string;varshift:tshiftstate;beginshift:=[];if ((wordrec(HotKey).hi shr 0) and 1)<>0 theninclude(shift,ssshift);if ((wordrec(HotKey).hi shr 1) and 1)<>0 theninclude(shift,ssctrl);if ((wordrec(HotKey).hi shr 2) and 1)<>0 theninclude(shift,ssalt);result:=shortcuttotext(shortcut(wordrec(hotkey).lo,shift));end;function ShiftStateToWord(Shift:TShiftState):Word;beginif ssShift in Shift then Result :=MOD_SHIFT;if ssCtrl in Shift then Result :=Result or MOD_CONTROL;if ssAlt in Shift then Result:=Result or MOD_ALT;end;
还有:(msg.LParamLo=MOD_CONTROL) and (msg.LParamHi=82)
MOD_CONTROL和82是虚拟键值吗?
ctrl+enter:
if(shift=[ssctrl])and(key=13)then
begin
//code here...
end;ctrl+a
if(shift=[ssctrl])and(key=97)then
begin
//code here...
end;