Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are a lot of pieces of software out there that do window management. You can check out a tiling window manager I've been hacking on called <a href="https://github.com/ianyh/Amethyst" rel="nofollow" title="Amethyst">Amethyst</a>. The basic idea behind software like this relies on Accessibility (which you can find documentation for <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Accessibility/cocoaAXIntro/cocoaAXintro.html" rel="nofollow">here</a>). As a quick overview the APIs work by acquiring references to accessibility elements (applications, windows, buttons, text fields, etc.) which have properties (hidden, position, size, etc.), some of which are writable.</p> <p>As an example let's say that you wanted to move all windows in every running application to the upper left corner of the screen. That code might look like</p> <pre><code>for (NSRunningApplication *runningApplication in [[NSWorkspace sharedWorkspace] runningApplications)] { AXUIElementRef applicationRef = AXUIElementCreateApplication([runningApplication processIdentifier]); CFArrayRef applicationWindows; AXUIElementCopyAttributeValues(applicationRef, kAXWindowsAttribute, 0, 100, &amp;applicationWindows); if (!applicationWindows) continue; for (CFIndex i = 0; i &lt; CFArrayGetCount(applicationWindows); ++i) { AXUIElementRef windowRef = CFArrayGetValueAtIndex(applicationWindows, i); CGPoint upperLeft = { .x = 0, .y = 0 }; AXValueRef positionRef = AXValueCreate(kAXValueCGPointType, &amp;upperLeft); AXUIElementSetAttributeValue(windowRef, kAXPositionAttribute, positionRef); } } </code></pre> <p>Which illustrates how you get references to applications and their windows, how to copy attributes from an accessibility element, and how to set attributes of an accessibility element.</p> <p>There are a variety of notifications documented in <code>NSWorkspace</code> for the launching and termination of applications, and the accessibility framework also has a sense of notifications for things like an application creating or destroying windows, or a window miniaturizing or deminiaturizing.</p> <p>Animating the window changes is non-trivial and I haven't figured out how to do it yet, though it may be possible. It may not be possible at all without hitting private APIs. But the other things you have listed should be possible. Hiding an application, for example, could be done by setting the <code>kAXHiddenAttribute</code> on the application accessibility element. Launching an application can actually be done via <code>-[NSWorkspace launchApplication:]</code>.</p> <p>Note that the use of accessibility necessitates that the user have <code>Enable access for assistive devices</code> turned on in <code>System Preferences &gt; Accessibility</code>.</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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