Changing Display colors

I am attempting to create a script that will change my display colors to 256 and back. I am able to get to opening the correct window but I am unable to select 256 colors. I am very new to this but am very willing to learn. Any help would be greatly appreciated.

This is what I have so far that works,

tell application “System Preferences”
activate
set current pane to �
pane “com.apple.preference.displays”

Read this:
http://www.apple.com/applescript/uiscripting/
Download the “UI Element Inspector” and learn to use it. Take a look to the examples at Apple’s site. You will come with something as the following:

tell application "System Preferences" to ¬
	set current pane to pane "com.apple.preference.displays"

--> wait a bit
delay 5

tell application "System Events"
	tell process "System Preferences"
		--> click the related popup button
		click pop up button 1 of group 1 of tab group 1 of window 1
		--> click the related menu item ("menu item 3" is "256 colores" in my machine)
		click menu item 3 of menu of pop up button 1 of group 1 of tab group 1 of window 1
	end tell
end tell

I have been trying this and have not been having success. I am not a Panther user yet so my question is do I have to be upgraded to Panther to get this to work?

Thanks

Get a copy of cscreen and install it (I placed mine in /usr/local/bin/) and then you can do a shell script call from AppleScript to it to change the resolution/depth of your monitor:

set old_depth to (word 2 of paragraph 3 of (do shell script "/usr/local/bin/cscreen -l"))
do shell script "/usr/local/bin/cscreen -d 8" --change to 256
delay 2
do shell script "/usr/local/bin/cscreen -d 16" --change to thousands
delay 2
do shell script "/usr/local/bin/cscreen -d 32" --change to millions
delay 2
do shell script "/usr/local/bin/cscreen -d " & old_depth --change back to previous setting

Jon

I know it is probably annoying to be helping such a novice but everybody has to start somewhere…How do I install cscreen? I saw this as a possibility when I was researching this but I wasn’t sure what to do with it.
Thank you for putting up with me.

If it helps…, the reason I want to do this is because I am an elementary computer coordinator and I am dealing with very young children and I need to make things almost automatic. They are using a classic program that will not turn the colors back after it turns them to 256. I would actually like to get the whole process encorperated so that the students start the classic app., and when they shut it down it turns the colors back to millons automatically. I was told that if I put the entire process into a script that it might be possible. If it is not I would settle for a script that simply needs to be activated after the application is shut down. I realize that the display can be set to be a menu item but the menu contains to many options for the little kids to choose. Also, I keep that hidden so the older kids don’t mess with it.
Thanks again,
Jerry

JJ had the right answer, but it might be better to activate the System Preferences app and quit it to prevent it from staying open forever.


tell application "System Preferences"
	activate
	set current pane to pane "com.apple.preference.displays"
	
	
	tell application "System Events"
		tell process "System Preferences"
			--> click the related popup button 
			click pop up button 1 of group 1 of tab group 1 of window 1
			--> click the related menu item ("menu item 3" is "256 colores" in my machine) 
			click menu item 3 of menu of pop up button 1 of group 1 of tab group 1 of window 1
		end tell
	end tell
	-->  Quit the Application
	quit
	
end tell