如何制作按住Alt键的同时键入按键s,h,e,n,g的响应事件?

解决方案 »

  1.   

    http://www.csdn.net/Develop/read_article.asp?id=22082综合使用:
    procedure OnSysKeyDown(AHnd: HWND; var AMsg: TWMSysKeyDown);
    procedure OnChar(AHnd: HWND; var AMsg: TWMChar);
        就可以吧,我没试过,你搞定它。
      

  2.   

    调试通过:
    (如果是Form响应时间,同时窗体上有WinControl,要设置窗体的KeyPreview=True)var
      Form1: TForm1;
      Stage: Integer;procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    begin
      if Key = 18 then
        Exit;  if Stage = 0 then
        if ((GetKeyState(VK_LMENU) and $80 <> 0) or (GetKeyState(VK_RMENU) and $80 <> 0)) and
          (GetKeyState(Ord('S')) and $80 <> 0) then
        begin
          Stage := 1;
          Exit;
        end
        else
          Stage := 0;  if Stage = 1 then
        if ((GetKeyState(VK_LMENU) and $80 <> 0) or (GetKeyState(VK_RMENU) and $80 <> 0)) and
          (GetKeyState(Ord('H')) and $80 <> 0) then
        begin
          Stage := 2;
          Exit;
        end
        else
          Stage := 0;  if Stage = 2 then
        if ((GetKeyState(VK_LMENU) and $80 <> 0) or (GetKeyState(VK_RMENU) and $80 <> 0)) and
          (GetKeyState(Ord('E')) and $80 <> 0) then
        begin
          Stage := 3;
          Exit;
        end
        else
          Stage := 0;  if Stage = 3 then
        if ((GetKeyState(VK_LMENU) and $80 <> 0) or (GetKeyState(VK_RMENU) and $80 <> 0)) and
          (GetKeyState(Ord('N')) and $80 <> 0) then
        begin
          Stage := 4;
          Exit;
        end
        else
          Stage := 0;  if Stage = 4 then
        if ((GetKeyState(VK_LMENU) and $80 <> 0) or (GetKeyState(VK_RMENU) and $80 <> 0)) and
          (GetKeyState(Ord('G')) and $80 <> 0) then
        begin
          ShowMessage('ok');
          Stage := 0;
        end
        else
          Stage := 0;
    end;
      

  3.   

    用键盘HOOK呵
    不过字符键总归不能几个同时按,要按顺序:)
      

  4.   

    if (Msg.message = WM_KEYDOWN) then
      begin
        case (Msg.wParam) of
          ord('R'):
            if (GetKeyState(VK_CONTROL) and $80 = $80) then
              __S := __S + 'r';
          ord('E'):
            if (GetKeyState(VK_CONTROL) and $80 = $80) then
              __S := __S + 'e';
          ord('D'):
            if (GetKeyState(VK_CONTROL) and $80 = $80) then
            begin
              __S := __S + 'd';
              if StrUpper(PChar(__S)) = 'RED' then begin
                Self.Image1.Visible := True;
              end;
              __S := '';        end;
        else
          __S := '';
        end;
      end;
      

  5.   

    要设置窗体的KeyPreview=True
    if (shift=[ssCTRL]) and (key>=$41) and (key<=$5A)  then
    begin
    keytp:=keytp+chr(key);
    if keytp='ZT' then
    begin
    showmessage('ztqy-20031219')
    end;
    end;