I've done some tests with Lazarus, but i'm not familiar enought with Pascal, anyway i guess you need to override something like that (Delphi): procedure TWindow.WndProc(var Msg: TMessage); begin // do your stuff Inherited WndProc(Msg); end; Short example in pure AutoIt: One programm to create a window with a custom WindowProc handling a custom 0x401 msg : #cs FROM MSDN: Application-Defined Messages An application can create message