Re: setting application and window focus
Re: setting application and window focus
- Subject: Re: setting application and window focus
- From: "Ian Archer" <email@hidden>
- Date: Wed, 29 Mar 2006 14:58:56 -0500
I suppose alternatively you can hide your process through
ShowHideProcess. I've never used it but it might be worth a shot.
As a Cocoa app you can also receive app focus events through the
notification center. this would allow you to maintain your own queue
of the current process in cases where the active process changes while
at your window.
I've heard that the process manager's queue is ordered but I don't
know if this is the case. If it is, you could use getnextprocess to
move to the next in the queue.
There's a discussion page at
http://www.cocoadev.com/index.pl?ResignFrontmostApplication that
offers these solutions.
On 3/29/06, Keith Alperin <email@hidden> wrote:
> Thanks to Tom Bunch and Ian Archer for supplying this answer. It
> worked like a charm.
>
> Yes, some of those calls were failing, and even the ones that
> succeeded didn't succeed in focusing on the correct app.
>
> Cheers!
> Keith
>
> On Mar 29, 2006, at 11:05 AM, Tom Bunch wrote:
>
> > I realize that you may have omitted code, but some of these should
> > be failing with kAXErrorIllegalArgument. Are you checking theErr?
> >
> > That said, I don't actually know if there is an Accessibility API
> > that lets you set the focused app. I would try
> >
> > extern OSErr GetFrontProcess(ProcessSerialNumber * PSN);
> > extern OSErr SetFrontProcess(ProcessSerialNumber * PSN);
> >
> > -Tom
> >
> > On Mar 29, 2006, at 8:41 AM, Keith Alperin wrote:
> >
> >> Greetings Accessibility-devs!
> >>
> >> I have a cocoa agent application (one that does not show up in the
> >> dock, though it can come forward and present a UI). I use a hot
> >> key to bring up a window from my agent app and then do something.
> >> When it is done, i hide the window and want to return focus the
> >> previously focused window. I keep AXUIElementRefs of the focused
> >> Application, window and even kAXFocusedUIElementAttribute from
> >> before i change focus to my agent app. I've tried a number of
> >> ways to return focus to the original window, but none of them seem
> >> to work:
> >>
> >> theErr = AXUIElementSetAttributeValue
> >> (previouslyFocusedApplication, kAXMainAttribute, kCFBooleanTrue);
> >> theErr = AXUIElementSetAttributeValue
> >> (previouslyFocusedApplication, kAXFocusedApplicationAttribute,
> >> kCFBooleanTrue);
> >> theErr = AXUIElementSetAttributeValue(previouslyFocusedWindow,
> >> kAXFocusedWindowAttribute, kCFBooleanTrue);
> >> theErr = AXUIElementSetAttributeValue(previouslyFocusedWindow,
> >> kAXMainAttribute, kCFBooleanTrue);
> >> theErr = AXUIElementSetAttributeValue(previouslyFocusedWindow,
> >> kAXFocusedAttribute, kCFBooleanTrue);
> >> theErr = AXUIElementSetAttributeValue
> >> (previouslyFocusedApplication, kAXFocusedUIElementAttribute,
> >> previouslyFocusedElement);
> >>
> >> after each of these, i check what the
> >> kAXFocusedApplicationAttribute of the system wide element is and
> >> it's always my agent application. I'm not that experienced with
> >> the Accessibility API, is there a simple way to set the focus of a
> >> specific application and window?
> >>
> >> Many thanks,
> >> Keith R. Alperin
> >> _______________________________________________
> >> Do not post admin requests to the list. They will be ignored.
> >> Accessibility-dev mailing list (Accessibility-
> >> email@hidden)
> >> Help/Unsubscribe/Update your Subscription:
> >> 40omnigroup.com
> >>
> >> This email sent to email@hidden
> >
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Accessibility-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Accessibility-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden