Applescript to Adjust Monitor Brightness

Discussion in 'Mac Applications and Mac App Store' started by Lostanddamned, Jul 1, 2009.

  1. macrumors 6502a

    Lostanddamned

    Joined:
    May 3, 2009
    Location:
    London, UK
    #1
    I'm currently writing an applescript to use as an alarm clock (playing itunes at full blast, displaying my dashboard with the weather and news), but of course, to actually get to sleep I have had to turn the brightness of the monitor right down, which means that I have to manually turn it back up again.

    The Script I am currently using is
    Code:
    tell application "System Preferences"
    	activate
    	set current pane to pane "com.apple.preference.displays"
    	tell application "System Events"
    		delay 5
    		set value of slider 1 of group 2 of tab group 1 of window "Color LCD" of process "System Preferences" to 0.5
    		delay 5
    	end tell
    	quit
    end tell
    But this returns the error "System Events got an error: Can't set window "Color LCD" of process "System Processes" to 0.5"

    any ideas what I am doing wrong?
     
  2. macrumors newbie

    Joined:
    Sep 26, 2011
    #2
    Change "Color LCD" to 1:
    PHP:
    tell application "System Preferences"
        
    activate
        set current pane to pane 
    "com.apple.preference.displays"
        
    tell application "System Events"
            
    delay 1
            set value of slider 1 of group 2 of tab group 1 of window 1 of process 
    "System Preferences" to 0.5
            delay 1
        end tell
        quit
    end tell
     
  3. macrumors newbie

    Joined:
    Feb 15, 2008
    #3
    "Color LCD" should work, as long as that is the correct name of your monitor. When you open display prefs yourself, what does it say at the top of the window? That is the name of your display.
     

Share This Page