Re: Problem with osascript command -- clarification
Re: Problem with osascript command -- clarification
- Subject: Re: Problem with osascript command -- clarification
- From: Mike Kobb <email@hidden>
- Date: Mon, 26 Nov 2007 15:46:24 -0800
It occurs to me that I didn't explain the crux of my question very
clearly, so here it is:
When I run this script in Script Editor, System Preferences never
launches. But, when I run the same script via osascript, System
Preferences *launches* if it wasn't already running, and this behavior
is very much undesirable. The script is explicitly trying to check
for whether the app is running, so I don't know what I'm doing wrong.
Thanks,
--Mike
On Nov 26, 2007, at 3:20 PM, Mike Kobb wrote:
Hi!
I'm developing a little script that needs to be executed via
osascript. It's getting run as part of an installer, and its job is
to quit System Preferences if it's open.
I've written the script in Script Editor and tested it, and it works
fine. However, when I invoke the same script with osascript, I'm
getting incorrect behavior. I'm hoping somebody can help me. This
is on Leopard, by the way (10.5.1).
Here's a scaled-down test case of my little script:
-- We refer to applications by id rather than name in case of
localization
tell application id "com.apple.systemevents"
set everyProcess to bundle identifier of every process
-- Start by quitting System Preferences, since we're installing a
new pref pane
if "com.apple.systempreferences" is in everyProcess then
-- activate first, so that if quitting the app presents a dialog,
it will be visible
tell application id "com.apple.systempreferences" to activate
end if
end tell
As I noted, this works fine in Script Editor. If System Preferences
is running, it comes to the front. If it's not running, nothing
happens.
If I save this as a text file, then run it via osascript:
osascript myScript.txt
...then System Preferences launches to handle the "activate" message.
I've tweaked the script to show me the contents of everyProcess, and
com.apple.systempreferences is in there. Am I doing something wrong
(e.g. with my "is in" syntax), or...?
I'm sorry if this is a n00b question, but I'm a 20-year C++
programmer working my head around AppleScript. ;-)
Thanks much,
--Mike
PS: I've developed what I think are a couple of very handy scripts
for Safari. Is there a good place to post them?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (applescript-
email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden