- 注册时间
- 2011-3-6
- 最后登录
- 1970-1-1
该用户从未签到
|
我的代码如下。- unit Unit1;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, IniFiles, StdCtrls, ComCtrls, Spin,ShellApi;
- const NOTIFYEVENT = WM_USER + 100;
- type
- TForm1 = class(TForm)
- HotKey0: THotKey;
- HotKey1: THotKey;
- HotKey2: THotKey;
- procedure FormCreate(Sender: TObject);
- private
- { Private declarations }
- aatom:atom;
- abcd:atom;
- procedure hotkey(var msg:tmessage);
- message wm_hotkey;
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- MyHwnd:hwnd;//窗口
- implementation
- {$R *.dfm}
- procedure TForm1.FormCreate(Sender: TObject);
- var
- myhot:string;
- begin
- RegisterHotKey(handle,aatom,MOD_ALT,VK_F10); //注册热键ALT-F10
- //RegisterHotKey(handle,abcd,MOD_ALT,VK_F11);
- end;
- procedure TForm1.hotkey(var msg:tmessage);
- begin
- if (msg.LParamHi=VK_F10) and (msg.LParamLo=MOD_ALT) then
- begin
- MyHwnd:=GetForegroundwindow; //这里是不是获取热键Alt+F10按下后的当前窗口的句柄呢?
- begin
- SetForegroundWindow(handle);
- messagebox(handle,'你已经按下热键Alt+F10','成功', MB_OK);
- end;
- end;
- if (msg.LParamHi=VK_F11) and (msg.LParamLo=MOD_ALT) then
- SetForegroundWindow(handle);
- messagebox(handle,'你已经按下热键Alt+F11','成功', MB_OK);
- end;
- end.
复制代码 |
|