Title: Printscreen pressed ?
Question: Determine if the user pressed the printscreen key !
Answer:
In the keydown-event of TForm the printscreen key is not handled. This can be done by 'GetAsyncKeyState'. The GetAsyncKeyState function determines whether a key is up or down at the time the function is called, and whether the key was pressed after a previous call to GetAsyncKeyState.
The OnIdle-event of TApplication is good to call this API function:
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnIdle := AppIdle;
end;
procedure TForm1.AppIdle(Sender: TObject; var Done: Boolean);
begin
if GetAsyncKeyState(VK_SNAPSHOT) 0 then
Form1.Caption := 'PrintScreen pressed !';
Done := True;
end;