Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Blakeasd

macrumors 6502a
Original poster
Dec 29, 2009
643
0
Hello!
I recently thought of a great idea for window management, but it would require my app to be able to reposition and resize other app's windows. Is this possible and if so what framework could I use to do it.
Thanks! :D
 

LinusR

macrumors 6502
Jan 3, 2011
332
515
Hello!
I recently thought of a great idea for window management, but it would require my app to be able to reposition and resize other app's windows. Is this possible and if so what framework could I use to do it.
Thanks! :D

As far as I know there's no way to control other windows than the ones of your app.

Sorry
 

Kenndac

macrumors 6502
Jun 28, 2003
256
63
As far as I know there's no way to control other windows than the ones of your app.

This is incorrect - there are many apps already out there that manage and reposition windows belonging to other applications. Take a look at Grid on the Mac App Store, for instance.

One way of controlling other applications' windows is to use the Accessibility APIs.
 

Partron22

macrumors 68030
Apr 13, 2011
2,655
808
Yes
Another way to move an App's windows is through Applescript.
This little script will move a Firefox window over and down by 10 pixels:
Code:
set appname to "Firefox"

tell application appname to set nam to name of front window
tell application appname to set boundsrect to bounds of window nam

set newbds to {(item 1 of boundsrect) + 10, (item 2 of boundsrect) + 10, (item 3 of boundsrect) + 10, (item 4 of boundsrect) + 10}
tell application appname to set bounds of window nam to newbds
You can save the script as an App, or embed the script as part of your own App. Either way, it'll let you control another App's window.
 
Last edited:

Blakeasd

macrumors 6502a
Original poster
Dec 29, 2009
643
0
I looked through both the Carbon and the Cocoa accessibility APIs ,but I found nothing pertaining to moving other app's windows.
Thanks!
 

LinusR

macrumors 6502
Jan 3, 2011
332
515
I looked through both the Carbon and the Cocoa accessibility APIs ,but I found nothing pertaining to moving other app's windows.
Thanks!

That's what I meant: Although there are plenty of apps which control windows there's no official API to do this.
Some months ago I looked for even this API as well. But do you know one? I don't do.

And the Accessibility APIs are really limited in their functionality. There aren't a lot of ways to do this you want.

Nevertheless, never stop searching. I hope you'll find what you're looking for.

Linus
 

Partron22

macrumors 68030
Apr 13, 2011
2,655
808
Yes
Incidentally, that bit of AppleScript doesn't need "access for assistive devices" enabled in order to work.
It'll move Pages documents too, and likely the windows of the majority of Mac Applications.
The capability's been part of the OS since the mid nineties. Lion hasn't changed it much, except that you can now use XCode and Obj c to make a wrapper application for your scripts. You can do the same with Python and Ruby Scripts.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.