function KeyBHkHandle(iCode:Integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;export;
  const
    // SfileName='c:\logfile.txt';
     _keypressmask=$80000000;
  var
    pEvt:TEventMsg;
    hFocus:THandle;
    szTitle:array[0..255] of Char;
    Stream:TextFile;
    vKey:Integer;
    ch:Char;
    str:array[0..10] of Char;
    pt:TDateTime;
    time1:String;
    iCtrl,iAlt,iShift:Integer;
    iNumLock:Integer;
    iCapital:Integer;
    bAlt,bCtrl,bShift,bCapital,bNumlocl:Boolean;
    MouPos:TPoint;
    StrString:String;
    SPCH:Char;  begin
    Result:=0;
    if (iCode<0) then
    begin
    //  Result:=CallNextHookEx(hNextHookProc,iCode,wParam,integer(lParam));
      Result:=CallNextHookEx(hNextHookProc,iCode,wParam,lParam);
      exit;
    end;
    if iCode=HC_ACTION then
    begin
        pEvt:=PEventMsg(lParam)^;
        if (pEvt.message=WM_KEYDOWN) or (pEvt.message=WM_SYSKEYDOWN) then
                                          begin
       // vKey:=wParam;          myshiftchar:='';
          mypresschar:='';
          dulictrl:='';
          vKey:=LOBYTE(pEvt.paramL);
          if vKey=116 then mypresschar:='F5';
        end;   end;
   if mypresschar='F5' then begin
     form1.Memo1.Lines.Add(mypresschar);
     mypresschar:='';
     vKey:=0;
     showmessage('OK');  //只要加上这句,就停不下来,一直跑到死机
   end;end;
我想这里增加按下F5,就出来一个提示信息,

解决方案 »

  1. 再补充一下,showmessage('OK');  //只要加上这句,就停不下来,一直跑到死机,不加这句,可以检测到F5按键,也不会出现跑到死机的情况
      

  2. ShowMessage 是MODEL模式 用个自定义的窗口就好了!
      

类似问题 »