Re: Watching for new windows
Re: Watching for new windows
- Subject: Re: Watching for new windows
- From: Bill Cheeseman <email@hidden>
- Date: Wed, 19 Nov 2003 06:37:02 -0500
on 2003-11-18 7:03 PM, Modesitt Software at email@hidden wrote:
>
I created an application that uses the accessibility APIs to track
>
which window is the frontmost window from the current application. I
>
created an array of processes, and for each one I call
>
AXObserverCreate. My callback then calls AXUIElementCopyAttributeValue
>
to get the name of window title (using kAXTitleAttribute). This all
>
works fine except for one anomaly. When switching to some
>
applications, such as Codewarrior, my callback function gets called
>
twice. But when I switch to an application such as Mail, my callback
>
function isn't called until I open a new window in Mail. I suspect
>
this is because Codewarrior is a Carbon app, and Mail is a Cocoa app.
>
Can this be confirmed? Is this the expected behavior?
Your diagnosis is correct (Carbon vs. Cocoa target). It is a known bug in
Carbon or in the Accessibility API that has been there from the beginning.
It only happens with the activated/deactivated and hidden/shown pairs.
In my app, I work around it by some very complex gymnastics. Whenever the
user registers one notification in a pair, I force registration of the other
notification in the same pair. In the callback for these notifications, I
have a global variable that keeps track of whether the same notification has
come in a second time from the same target without an intervening
notification of the other item in the pair from the that target. If so, I
ditch the second notification. This works on the theory that, for example,
two valid deactivate notifications in a row couldn't come from the same
target without an intervening activate notification from that target, so the
repetition is necessarily a result of this bug. The beauty of this
workaround is that it works without knowing whether the target is a Carbon
or a Cocoa app, and the code will continue to work correctly even after the
bug is fixed.
Apple really ought to fix it.
--
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
_______________________________________________
accessibility-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/accessibility-dev
Do not post admin requests to the list. They will be ignored.