Recent

Author Topic: Get a window handle knowing the PID of a third-party process in Linux  (Read 852 times)

prostor_7_7_7

  • Newbie
  • Posts: 1
How is it possible in Lazarus(linux) to get a window handle knowing the PID of a third-party process in Linux. Perhaps an analogue of the function for Windows enumthreadwindows

I looked at the lclintf.pas module, there are some functions from Winapi. But there is no getting a list of HWND windows, running processes

MarkMLl

  • Hero Member
  • *****
  • Posts: 7496
Re: Get a window handle knowing the PID of a third-party process in Linux
« Reply #1 on: April 26, 2024, 04:24:05 pm »
How is it possible in Lazarus(linux) to get a window handle knowing the PID of a third-party process in Linux. Perhaps an analogue of the function for Windows enumthreadwindows

I looked at the lclintf.pas module, there are some functions from Winapi. But there is no getting a list of HWND windows, running processes

With a lot of difficulty IMO since apart from anything else one PID (on the client program) can be talking to multiple windows (on an X11 server... don't get me going about Wayland).

I've had some measure of success parsing the output of xwininfo and xprop, in principle there must be lower-level libraries which could be used but I've not worked out the details.

Code: [Select]
A complete list of windows may be obtained using e.g.

xwininfo -tree -root | less

A name pattern may be searched from this, hence e.g.

0x520000c "Untitled * — Kate"

The window info may be obtained e.g.

xwininfo -id 0x520000c

The name may be verified and PID (assuming this is local etc.) obtained e.g.

xprop -id 0x520000c WM_NAME _NET_WM_PID

Hence the screensaver may also be suspended

xdg-screensaver suspend 0x520000c

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

 

TinyPortal © 2005-2018