Screen Brightness

I’m trying to get an Apple Script to reduce my screen brightness at night, and then a second one (probably) to reset it in the morning. I use my laptop as my alarm clock, but I need to leave it running at night for processes to run…Obviously I don’t want the bright screen at night, but I need it for my clock screen saver in the morning…I’ve found the following script, but everytime I run it, I get the following error:
System Events got an error: NSReceiverEvaluationScriptError: 4

I have an iBook G4 running 10.4.10

Supposedly this has worked in the past, but the forum I got it off of was several years old, and my applescript knowledge is limited at best, and there’s no time like the present to learn.

set V to 0.6

tell application "System Preferences"
	set current pane to pane ""
end tell

tell application "System Events"
	tell process "System Preferences"
		tell slider 1 of group 2 of tab group 1 of window 1
			set value to V
		end tell
	end tell
end tell

tell application "System Preferences" to quit


your code is great, it works fine on my machine.
The only question is: Is “Enable access for assitive devices” enabled in Universal Access SysPrefs?

ha! thank you, that was exactly what I needed…is that a common requirement with applescripts?

It’s required using GUI scripting

Thanks so much, I’ve found an application that does a better of job what I was originally intending, to put the display to sleep easily, this works great! contains a simple Objective-C command line utility for setting screen brightness.