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 11:50:28 -0500
You should try the function:
OSErr SetFrontProcess (
const ProcessSerialNumber * PSN
);
Save the psn of the previous process and call this method. You
shouldn't need to focus the previous window (as it will still be the
foremost window of the process).
On 3/29/06, Keith Alperin <email@hidden> 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 (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