Hi
GetActiveWindow doesn't works : you get the active window of your thread, never working with an other process (always return 0)
Only GetForegroundWindow can return handle for active window, not depending of the process.
It works good... Except if you're working with ubuntu 16.04 Lazarus 1.6 x64 :-(
ludo