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?


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?

Leo


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.

Kind regards,

Gerriet.




_______________________________________________

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

Reply via email to