Re: XCode 2.4 Affects "do shell script"?
Re: XCode 2.4 Affects "do shell script"?
- Subject: Re: XCode 2.4 Affects "do shell script"?
- From: "Laine Lee" <email@hidden>
- Date: Tue, 17 Oct 2006 11:27:01 -0500
On 10/17/06 8:47 AM, "Marconi" <email@hidden> wrote:
> I have a pair of one line scripts:
>
> do shell script "pmset -a dim 1" password "xxxxxx" with administrator
> privileges
> and
> do shell script "pmset -a dim 60" password "xxxxxx" with
> administrator privileges
>
> I use these to set the Energy Saver pref pane to dim the screen in 1
> and 60 minutes, respectively.
>
> Each time I invoke these now, I receive a dialog:"System Event
> requires that you type your password."
No such problem here. You're running the app while logged in as admin?
Here's the script I used. You probably only need the password once because
the commands are being run successively with no pause.
----
on clicked theObject
(*Add your script here.*)
if name of theObject is "doit" then
try
do shell script "pmset -a dim 1" password "XXXXXXXX" with administrator privileges
do shell script "pmset -a dim 60" with administrator privileges
end try
set contents of text field "sign" of window "main" to "Done."
else if name of theObject is "cancel" then
quit
end if
end clicked
on awake from nib theObject
(*Add your script here.*)
set contents of text field "sign" of window "main" to "Click the button to set screen dimming."
end awake from nib
on will open theObject
(*Add your script here.*)
center theObject
end will open
----
If you want to test it note for note (word for word) follow these steps. This may take you five minutes unless you're really good.
Create new Applescript app with Xcode's "New Project" command
Paste the above script into the default script replacing anything there.
In IB select the window, do command 8 (or whichever number brings up the
Applescript name field), then name the window "main" and attach it to the
default script with "on will open" checked.
In iB drag a text field into the window, do command 8, then name the text
field "sign" and attach it to the default script with "on awake from nib"
checked.
In iB drag a button into the window, do command 8, then name the button
"cancel" and attach it to the default script with "on clicked" checked.
In iB drag a button into the window, do command 8, then name the button
"doit" and attach it to the default script with "on clicked" checked.
Save, build and run.
--
Laine Lee
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden