| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
_______________________________________________
On Nov 11, 2003, at 3:40 PM, Modesitt Software wrote:
I put together the code, but every time it runs, AXObserverAddNotification always returns the error kAXErrorCannotComplete. I've tried several modifications, but nothing changes. Is that most likely because of a code error my part, or is it because these calls are still in "draft" mode?
The calls definitely work; I've written code myself that uses them.
ProcessSerialNumber psn = UProcess::GetPSN( "\pmail");
pid_t pid = psn.lowLongOfPSN;
Have you verified that the PSN that you're getting back is valid?
I'd suggest using GetProcessPID here instead of constructing the pid_t from the PSN.
AXUIElementRef elementRef = ::AXUIElementCreateApplication (pid);
AXObserverRef observerRef;
AXError err = ::AXObserverCreate ( pid,
(*(AXObserverCallback)MyObserverCallback),
&observerRef);
err = ::AXObserverAddNotification ( observerRef,
elementRef,
kAXMainWindowChangedNotification,
nil );
// err always returns kAXErrorCannotComplete
This part looks OK, except I'm not sure you need to dereference the MyObserverCallback parameter to AXObserverCreate. But I wouldn't think that would cause kAXErrorCannotComplete to be returned later.
-eric
| References: | |
| >Re: Need to find which window is active (From: Modesitt Software <email@hidden>) | |
| >Re: Need to find which window is active (From: Eric Schlegel <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
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.