jfreak53
jfreak53

Reputation: 2369

Linux - XFCE4 - Lazarus system wide hotkey

I have done quite a bit of searching in Google and though I can find the switches to do this for Windows using WM_HOTKEY I cannot find it for Linux.

WM_HOTKEY Hook

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;

I am looking to place a system wide hotkey hook in XFCE4 and/or XWindows on a linux machine. I know it is possible as many screenshot programs do this all the time no matter what the Window Manager is.

I need for my app to be able to hook a key combo to activate something inside the app but I cannot find anything for this with Lazarus/Pascal on linux anywhere.

Upvotes: 2

Views: 626

Answers (1)

vitt
vitt

Reputation: 11

Marco knows more about FPC than most (think he wrote it).

In any event you may find the code at the link below helpful and/or other portions of the code base:

http://code.google.com/p/ovoplayer/source/browse/trunk/src/platform/darwin/mmkeys.inc?spec=svn206&r=206

Upvotes: 1

Related Questions