Mac Forums

Mac Forums (http://www.mac-forums.com/forums/)
-   OS X - Development and Darwin (http://www.mac-forums.com/forums/os-x-development-darwin/)
-   -   Switch Displays w/ Applescript (http://www.mac-forums.com/forums/os-x-development-darwin/205145-switch-displays-w-applescript.html)

photon43 06-14-2010 09:11 PM

Switch Displays w/ Applescript
 
This is one of those things that I think should be really easy to do but for some reason I can't find any useful info on it.

I have one of the new iMac 21" models and a 42" HDTV mounted above it - great for movies and a general media center. Now, when I want to watch a movie I have to do several things to prep for this:

1) Open system prefs and switch the main display to the top 42" screen.
2) Open the desktop and screen saver pane and set the desktop BG to solid black for the lower screen (b/c there is no way to shut it off and having it any other color is distracting during a movie)

Now, none of this is particularly annoying really, Butů It does take like 7 or more clicks to get it done.

I would like to automate the whole process of course - b/c I should be able to, there is just no reason why not. I want to run a script that switches the desktop from bottom to top monitor, changes the desktop BG from gray to black at the bottom monitor (the iMac) and then have another script that does this all in reverse (more on this idea below) for when I need to get back to work. It really does not seem like such a tall order but I can find no answers anywhere.

The following script is the best I could find (I did not write this - just modified the paths a bit) but all it does is change the BG of the desktop:

set buttonList to {"work", "movies"}
set colorList to {"Solid Gray Medium", "Solid Black"}
display dialog "Which environment?" buttons buttonList default button 1
set selectedButton to the button returned of the result

repeat with index from 1 to 3
if item index of buttonList = selectedButton then exit repeat
end repeat

set selectedColor to item index of colorList

tell application "Finder"
set desktop picture to {"BobaFett4:Libraryesktop Pictures:Solid Colors:" & selectedColor & ".png"} as alias
end tell

I need it to go a bit further but this is perfect because it eliminates the need for the 'reverse' script I was talking about before because of the buttons it gives me. I could just switch between the two sates (work and movies) at will if I could get some code that would take care of the main display switch along with the BG color switch. But I cant figure out how to take this to the next level. Please help if you can. Thanks!


All times are GMT -4. The time now is 04:31 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.