早上brightyang帮我解决的注册热键盘的问题,在这里谢谢他了。但是又有新的问题我用RegisterHotKey不能给组键注册多个热键的。不知道这个是要怎么实现,能不能给我指点指点各位大大。代码如下,但是不能实现。

解决方案 »

  1.   

    unit Unit1;interfaceuses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls;type
    TForm1 = class(TForm)
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    protected
    procedure hotykey(var msg:TMessage); message WM_HOTKEY;
    end;var
    Form1: TForm1;
    HotKey:Integer;
    hw:hwnd;
    pid: hwnd;
    hProcess: hwnd;
    Num: Cardinal;
    implementation{$R *.DFM}
    procedure TForm1.hotykey(var msg:TMessage);
    begin
    if (msg.LParamLo=MOD_ALT) and (msg.LParamHi=VK_F8) then
    checkbox1.Checked:=not checkbox1.Checked
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
    hw:=findwindow(nil,'readme22.txt - 记事本');
    HotKey:=GlobalAddAtom('HotKey');
    RegisterHotKey(handle,HotKey,0,VK_F8);
    RegisterHotKey(handle,HotKey,MOD_ALT,VK_F8);
    end;procedure TForm1.FormDestroy(Sender: TObject);
    begin
    UnRegisterHotKey(handle,HotKey);
    end;procedure TForm1.CheckBox1Click(Sender: TObject);
    begin
        GetWindowThreadProcessId(hw, @pid);
       if checkbox1.Checked then
        showwindow(hw,SW_HIDE)
      else
        showwindow(hw,SW_SHOW);
    end;end.
      

  2.   

    RegisterHotKey的第2个参数对应
    WM_HOTKEY消息的wParam参数
    所以你不能
    HotKey:=GlobalAddAtom( "HotKey "); 
    RegisterHotKey(handle,HotKey,0,VK_F8); 
    RegisterHotKey(handle,HotKey,MOD_ALT,VK_F8); 
    要分开申请
    HotKey1:=GlobalAddAtom('HotKey1'); 
    RegisterHotKey(handle,HotKey1,0,VK_F8); 
    HotKey2:=GlobalAddAtom('HotKey2'); 
    RegisterHotKey(handle,HotKey2,MOD_ALT,VK_F8); procedure   TForm1.hotykey(var   msg:TMessage); 
    begin 
    if msg.wParam =HotKey1 then;
    ...
    ...
    if msg.wParam =HotKey2 then;
    ...
    ...
    end;