title: Get NSWindow* from CGWindowListCopyWindowInfo
body: <p>I have accomplished listing all the windows (in z order from front to back I think/hope) using <code>CGWindowListCopyWindowInfo</code> but I am having an issue getting the <code>NSWindow*</code> from it so I can use with <code>orderFront:</code> etc.</p>
  
  <p>It seems I don't even get <code>CGWindowID</code> from it.</p>
  
  <p>This is my code, it is js-ctypes.</p>
  
  <pre><code>var cfarr_win = ostypes.API('CGWindowListCopyWindowInfo')(ostypes.CONST.kCGWindowListOptionAll | ostypes.CONST.kCGWindowListExcludeDesktopElements, ostypes.CONST.kCGNullWindowID);
  
  var cnt_win = ostypes.API('CFArrayGetCount')(cfarr_win);
  
  for (var i = 0; i &lt; cnt_win; i++) {
      var thisWin = {};
      // trying to get NSWindow* to the window here, so i can use with orderFront: etc
  
      // example on how i get pid:
      var rez_pid = ostypes.API('objc_msgSend')(c_win, ostypes.HELPER.sel('objectForKey:'), myNSStrings.get('kCGWindowOwnerPID'));
      var int_pid = ostypes.API('objc_msgSend')(rez_pid, ostypes.HELPER.sel('integerValue'));
      thisWin.pid = int_pid;
  
      // How can I get NSWindow*
  
  }
  </code></pre>
  
  <p>PS: Even though I am using the exclude desktop elements flag I am still get desktop elements like cursor and dock, by any chance if answerer can shed some light on how to fix that too that would be awesome!</p>