Статьи по Delphi (026)…

Как глобально перехватить нажатие кнопки PrintScreen?

Как глобально перехватить нажатие кнопки PrintScreen?

В примере для глобального перехвата нажатия клавиши print screen регистрируется горячая клавиша (hot key).

Code: Type. TForm1 = class(TForm). Procedure FormCreate(Sender: TObject); Procedure FormDestroy(Sender: TObject); Private. { Private declarations }. Procedure WMHotKey(var Msg : TWMHotKey); message WM_HOTKEY; Public. { Public declarations }. End; Var. Form1: TForm1; Implementation. {$R *.DFM}. Const id_SnapShot = 101; Procedure TForm1.WMHotKey (var Msg : TWMHotKey); Begin. If Msg.HotKey = id_SnapShot then. ShowMessage('GotIt'); End; Procedure TForm1.FormCreate(Sender: TObject); Begin. RegisterHotKey(Form1.Handle, Id_SnapShot, 0, VK_SNAPSHOT); End; Procedure TForm1.FormDestroy(Sender: TObject); Begin. UnRegisterHotKey (Form1.Handle, id_SnapShot); End;

©Drkb::01506.