title: Swift unable to access other application windows
body: <p>I'm trying to access the windows of running applications through my application. Currently, I am grabbing the data of all running applications, and the kCGWindowNumber mapped to the applications, but I am having trouble getting the window mapped to that kCGwindowNumber.</p>
  
  <p>How can I reference my windows of other running applications through mine? I have the kCGWindowNumber of those applications, but cannot figure out how to get access to the windows. </p>
  
  <p>This is how I grab my data</p>
  
  <pre><code>let options = CGWindowListOption(arrayLiteral: CGWindowListOption.excludeDesktopElements, CGWindowListOption.optionOnScreenOnly)
  let windowListInfo = CGWindowListCopyWindowInfo(options, CGWindowID(0))
  </code></pre>
  
  <p>Then, I store it into an object, which represents my running application. E.g.</p>
  
  <pre><code>{
      kCGWindowAlpha = 1;
      kCGWindowBounds =     {
          Height = 22;
          Width = 3840;
          X = 5520;
          Y = 0;
      };
      kCGWindowLayer = 24;
      kCGWindowMemoryUsage = 341416;
      kCGWindowNumber = 190;
      kCGWindowOwnerName = "Google Chrome";
      kCGWindowOwnerPID = 272;
      kCGWindowSharingState = 1;
      kCGWindowStoreType = 2;
  }
  </code></pre>
  
  <p>Now that I have the kCGWindowNumber I was trying to access the other applications with this</p>
  
  <pre><code>NSApplication.shared.window(withWindowNumber: kCGWindowNumber_FOR_WINDOW_I_WANT)
  </code></pre>
  
  <p>but, after reading the documentation I realized that NSApplication.shared returns Returns the application instance, and these windows are not not apart of my application.</p>