Finding the process that a window belongs to

Last edited on

On macOS

  1. Download pid_for_moved_window.py .

  2. Make it executable (in a shell):

    chmod 740 pid_for_moved_window.py
  3. Execute it (in a shell) and move the desired window a little bit on the screen (within 3 seconds):

    ./pid_for_moved_window.py

Example execution and output:

myuser@mycomputer somefolder % ./list_moved_window.py
Move target window (within 3 seconds)...

Moved window belongs to process with ID (PID): 94464

Process information ('ps -p 94464'):

  PID TTY           TIME CMD
94464 ??         8:06.88 /System/Applications/Utilities/Activity Monitor.app/Contents/MacOS/Activity Monitor

On Unix

It is possible to discover which process a window belongs to by using the xprop command line tool (which is part of the Debian package x11-utils).

  1. Execute the following command in a shell:

    xprop _NET_WM_PID | sed 's/_NET_WM_PID(CARDINAL) = //'
  2. Click on the window whose process should be identified. (If the desired window is not visible, use Alt+Tab to bring it to the foreground.) The above command should then output the process ID, for example:

    923
    

To output the parent process ID (PPID), process ID (PID) and the complete command used for executing a process, the following command can be used (in the same way):

ps ww -o ppid=,pid=,cmd= -q `xprop _NET_WM_PID | sed 's/_NET_WM_PID(CARDINAL) = //'`

Example output:

    854    2101 /usr/lib/firefox/firefox https://www.froglogic.com

On Windows

It is possible to discover which process a window belongs to by using the Process Explorer tool.

  1. Start Process Explorer:

  2. Drag and drop the "Find Windows's Process" symbol onto the window whose process should be identified:

    After the drop, Process Explorer selects the process that the window belongs to:

  3. Double click (or right click and choose Properties from context menu) the respective process to show its more of its details: