How to hook mouse in Delphi

It's very simple. Just drop TMouseHook component onto your form and use its events to get complete information about all mouse events. TMouseHook has standard mouse events (OnMouseMove, OnMouseDown, OnMouseUp, etc.) as well as OnMouseHook event for access raw hook data.

procedure TFormMain.MouseHookMouseHook(Sender: TObject; Message: Word;
  Point: TPoint; MouseData, Flags, Time: Integer; ExtraInfo: Pointer);
    IntToHex(Message,8)+' '+
    IntToStr(Point.X)+':'+IntToStr(Point.Y)+' '+
    IntToHex(MouseData,1)+' '+
    IntToHex(Flags,1)+' '+
    IntToStr(Time)+' '+

TMouseHook component works system-wide and does not require external DLL.

See also
Mouse Hook
Keyboard Hook
Components for Delphi / C++ Builder
Howtos for Programmers