On 2 Feb 2012, at 00:51, Leo wrote: > What happens if you send > > set frontmost of process yourApp to false > > then, using the name of your app? Will it reveal the previous app by a chance?
It seems that "process" has to be followed by a number. I tried this in AppleScript Editor: tell application "System Events" set proCount to count of processes repeat with x from (1) to (proCount) set appName to name of process x if appName = "AppleScript Editor" then set frontmost of process x to false exit repeat end if end repeat end tell and it had no effect and no error messages. Tried it inside my app - again, no effect. > If not, then is there any way to capture the name of the app you need to > activate at an earlier stage, so you can send it "set frontmost to true" > later? I am getting the previous app by watching for the relevant Carbon events. But then there is no need to use Apple Script to activate it - activateWithOptions: is probably more efficient. Kind regards, Gerriet. > > > On 2/1/12 1:44:49 AM, Gerriet M. Denkmann wrote: >> On 1 Feb 2012, at 11:33, Leo wrote: >> >>> If I understand your goals correctly, you can send the following >>> AppleScript script: >>> >>> tell application "System Events" to set frontmost of process yourApp to true >> I tried the following in AppleScript Editor: >> >> set appList to "processes" >> tell application "System Events" >> set proCount to count of processes >> set appList to appList& "("& proCount& "):" >> repeat with x from (1) to (proCount) >> set appName to name of process x >> set appList to appList& appName& "," >> end repeat >> end tell >> log appList >> >> >> But the resulting list of apps has only a very rough resemblance to the list >> displayed by Command-Tab. >> >> So the following: >> NSString *source = @"tell application \"System Events\" to set frontmost of >> process 2 to true"; >> NSAppleScript *appleScript = [ [ NSAppleScript alloc ] initWithSource: >> source ]; >> NSDictionary *errorInfo; >> NSAppleEventDescriptor *aed = [ appleScript executeAndReturnError:&errorInfo >> ]; >> [ appleScript release ]; >> >> does work in that is activates some app, but process 2 is NOT the previous >> active app. >> _______________________________________________ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com