On May 26, 2011, at 7:21 PM, Jerry Krinock wrote:

> I just thought I'd lift my head up long to say thank you, Anders.  
> Unfortunately, your code doesn't work in my app.  Tried several mutations; 
> still no good.
> 
> Another thing I learned is that programmatically switching apps, simulating 
> the user typing cmd-tab, which works when the user does it, does not work 
> when the program does it.  I hard-coded pids of several running programs, 
> activated each for 1 second, then activated my app.  Looked very impressive 
> until it got to my app, and the menu bar continued to show the 
> previously-activated app.

This is an unfortunate bug, but you should be able to work around it with this 
sequence:

                [[NSApplication sharedApplication] hide: nil];

                ProcessSerialNumber psn = {0, kCurrentProcess};
                verify_noerr(TransformProcessType(&psn, 
kProcessTransformToForegroundApplication));

                [[NSApplication sharedApplication] 
activateIgnoringOtherApps:YES];

—Jim

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to