Applescript EnergySaver preferences for quick automated use

I have been trying to create an applescript that will display a dialog then change the energysaver system preference based on what you have picked and then quit out of system preferences. kind of like what you had done with your netowrking script.
I have created an alias, EnergySaver, in my hard drive, known as Drake, so that way when that line is executed EnergySaver automatically opens
so far this is what ii have…

display dialog “What energy setting would you like to Change to?” buttons {“Cancel”, “High Perfomance”, “Long Battery Life”} default button 3
if the button returned of the result is “High Perfomance” then
tell application “Finder”
open the file “EnergySaver” of disk “Drake”
end tell

quit application "System Preferences"

else
tell application “Finder”
open the file “EnergySaver” of disk “Drake”
end tell

This opens energy saver and quits but doesnt change the preference. I was wondering if you know the code to change the setting in the energy saver with applescript.

Are you using Mac OS X, or an earlier version of Mac OS? The Energy Saver is a Preference Pane in Mac OS X, which would require GUI scripting.

I notice that, in Panther, one can query System Events to determine if UI scripting is enabled.

http://www.apple.com/applescript/uiscripting/01.html

I wonder if any of the Panther pref panes have gained scriptability.

– Rob

In Jaguar you can run this code to open the Pref Panes…

Just change the last word (sound) of “com.apple.preference.sound” to open the Pref Pane of your choice.

I am running mac os X jaguar