Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you want to avoid using private APIs you can take advantage of the fact Mission Control has keyboard shortcuts for moving to various spaces, and you can programmatically send the key codes to activate them. I wrote a blog post about it (<a href="http://ianyh.com/blog/2013/06/05/accessibility/" rel="nofollow">http://ianyh.com/blog/2013/06/05/accessibility/</a>) for a tiling window manager I've been working on called <a href="http://github.com/ianyh/Amethyst" rel="nofollow">Amethyst</a>, which has some example code you can check out in <code>-[AMWindow moveToSpace:]</code>.</p> <p>The short version is moving to a space looks something like using the default <code>ctrl + arrow key</code> to move to adjacent spaces:</p> <pre><code>CGEventRef keyboardDownEvent = CGEventCreateKeyboardEvent(NULL, kVK_RightArrow, true); CGEventRef keyboardUpEvent = CGEventCreateKeyboardEvent(NULL, kVK_RightArrow, false); CGEventSetFlags(keyboardDownEvent, kCGEventFlagMaskControl); CGEventSetFlags(keyboardUpEvent, 0); CGEventPost(kCGHIDEventTap, keyboardDownEvent); CGEventPost(kCGHIDEventTap, keyboardUpEvent); CFRelease(keyboardEvent); CFRelease(keyboardEventUp); </code></pre> <p>You could combine this with <code>NSWorkspaceActiveSpaceDidChangeNotification</code> to traverse all spaces and gather window data.</p> <p>Also, as a potentially interesting note the accessibility APIs can actually give you windows across all spaces at the same time, but it will only give you windows in spaces that you have traversed to since the process utilizing the APIs launched. I have no idea why this is the case, but it does seem to be.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload