Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need to find which window is active



on 03-11-01 12:20 AM, Eric Schlegel at email@hidden wrote:

> Using the accessibility APIs, you'd do something like this:
>
> - get the pid_t of an application
> - call AXUIElementCreateApplication with that pid
> - call AXObserverCreate with that pid
> - call AXObserverAddNotification with that AXUIElementRef and observer,
> passing kAXMainWindowChangedNotification as the notification
> - call AXObserverGetRunLoopSource on that observer
> - call CFRunLoopAddSource( GetCFRunLoopFromEventLoop(
> GetMainEventLoop() ), passing that run loop source
>
> Now your callback proc should be called when the main window (i.e., the
> active window) of that application changes.

And, just to be clear, what do you call when you want to stop watching? --

CFRunLoopRemoveSource
AXObserverRemoveNotification
CFRelease on the observer ref
CFRelease on the element ref

Or is some of that implicit? (Just checking my understanding.)


--

Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com

The AppleScript Sourcebook - http://www.AppleScriptSourcebook.com
Vermont Recipes - http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
carbon-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/carbon-development
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.