Re: Way to control another App's window
Re: Way to control another App's window
- Subject: Re: Way to control another App's window
- From: Bill Cheeseman <email@hidden>
- Date: Tue, 12 Sep 2006 08:13:42 -0400
- Thread-topic: Way to control another App's window
on 2006-09-12 7:06 AM, Bobby B at email@hidden wrote:
> For instance, I can send
> Safari, via AppleScript, "set bounds of window 1 to {1, 1, 800, 800}"
> and that can position a Safari window where I want it. I'm trying to
> accomplish a similar thing with Google Earth, so that I can position
> it's window in an appropriate location.. But I can't seem to find a
> Cocoa way to do this.
One Cocoa way to do this is to include some code based on Apple's
accessibility API in your app. Look up "accessibility" in the Xcode
documentation window (but don't limit the search to "Cocoa" in the left
pane, because the part of the accessibility API you want to use is not a
Cocoa API). The document you need to read is an old draft Release Note about
how to write "assistive" applications, which is what your application will
be. There are at least two Apple examples of how to do this in a Cocoa app
-- one is the old UIElementInspector 1.0 sample app.
Another Cocoa way to do this is to write an AppleScript using Apple's GUI
Scripting technology (which is based on the accessibility API under the
hood), then run it from within your Cocoa app. There's lots of documentation
online about how to do this. Start with
www.apple.com/applescript/uiscripting/ to begin learning how to write the
GUI Scripting script to control the window position of a non-scriptable or
partially scriptable application.
Either way, you will have to instruct your users to turn on the "Enable
access for assistive devices" setting in the Universal Access pane of System
Preferences. There is an API for doing this programmatically in Tiger, but
it doesn't work.
You can experiment with resetting the position of the Google Earth window
using the accessibility API by downloading the 30-day free trial version of
PreFab UI Browser at www.prefab.com/uibrowser/.
By the way, your initial post fooled me, too. For what it's worth, using the
accessibility API will not allow you to reposition the Google Earth window
simultaneously with the user's moving your app's window -- there will always
be a slight lag. This phenomenon is due to the latency inherent in the
notification feature of the accessibility API -- your app won't learn that
the Google Earth window has moved until a few moments later.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
PreFab Software - http://www.prefab.com/scripting.html
The AppleScript Sourcebook - http://www.AppleScriptSourcebook.com
Vermont Recipes - http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden