我想在TIMTER事件中随时检测是否程序按了ALT+S键,如果按了触发一些事件,怎么处理呢/谢谢了?好象是用到什么函数

解决方案 »

  1.   

    呵呵,为什么不是按alt+s后触发该事件,而是用timer检测呢?直接在onkeydown中写代码不行吗?
      

  2.   

    也可以处理WM_KEYDON消息阿.
      

  3.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ExtCtrls;type
      TForm1 = class(TForm)
        Timer1: TTimer;
        procedure FormKeyDown(Sender: TObject; var Key: Word;
          Shift: TShiftState);
        procedure Timer1Timer(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;
      isKeyDown:Boolean; //是否按下了Alt+s
    implementation{$R *.dfm}procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);begin  if (Shift=[ssAlt]) and (Key=83) then
           isKeyDown:=true;
    end;procedure TForm1.Timer1Timer(Sender: TObject);
    begin
      if isKeyDown then
        begin
          isKeyDown:=false;
          showmessage('按了Alt+S!');
        end;
    end;end.
      

  4.   

    if GetAsyncKeyState(VK_MENU)<0 and GetAsyncKeyState('S')<0 then