title: Get PIDs of all open windows on MacOS
body: <p>I tried to use the following <code>AppleScript</code> to get the <code>PID</code>s of all the windows (including ones that are minimized). This script doesn't get the <code>PID</code>s of windows on other desktops. </p>
  
  <p>Is there any workaround for this so I can still get a list of opened windows across all desktops without having to <code>activate</code> individual processes and checking if they have windows?</p>
  
  <pre><code>tell application "System Events"
      repeat with proc in (every process)
          if exists(first window of proc) then
              set pid to unix id of proc
              log pid
          end if
      end repeat
  end tell
  </code></pre>
  
  <p>PS, I'm not too proficient with AppleScript. I've managed to hack this together using StackOverflow. This might not be the most efficient way to do what I'm trying to do.</p>