The difficulty is that, contrary to Delphi, Lazarus doesn't allow to easily handle no user messages such as WM_HOTKEY. The following code does what you want (system wide F9 restores app):
uses ...,windows;
var
PrevWndProc: WNDPROC;
const
MY_ID=1;
function WndCallback(Ahwnd: HWND; uMsg: UINT; wParam: WParam; lParam: LParam):LRESULT; stdcall;
begin
if (uMsg=WM_HOTKEY) and (WParam=MY_ID) then
begin
Application.Restore;
end;
result:=CallWindowProc(PrevWndProc,Ahwnd, uMsg, WParam, LParam);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
PrevWndProc:=Windows.WNDPROC(SetWindowLong(Self.Handle,GWL_WNDPROC,PtrInt(@WndCallback)));
RegisterHotKey(Self.Handle,MY_ID,0,vk_F9);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
UnRegisterHotkey(Self.Handle,MY_ID);
end;