Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > macOS > Switch Displays w/ Applescript

Switch Displays w/ Applescript
Thread Tools
photon43
Fresh-Faced Recruit
Join Date: Jun 2010
Location: Charlotte
Status: Offline
Reply With Quote
Jun 14, 2010, 09:03 PM
 
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!
     
boy8cookie
Mac Elite
Join Date: Dec 2003
Location: I'll let you know when I get there...
Status: Offline
Reply With Quote
Jun 14, 2010, 10:03 PM
 
What are you watching movies in on the iMac?

If it's DVD Player, you can simply drag the window to the HDTV monitor (while it's set as the secondary monitor) and then enable full screen, and it will fill that monitor instead of the iMac's (DVD Player should remember this setting after the first time, too). DVD Player also has the option of "Dim other displays while playing" which sets the unused monitor to black.

Quicktime has similar functionality / options.
     
Person Man
Professional Poster
Join Date: Jun 2001
Location: Northwest Ohio
Status: Offline
Reply With Quote
Jun 15, 2010, 10:34 AM
 
There is an application called TV Row, which can change the main display without using the preferences. Set up the application's preferences to do what you want and then call it from your Applescript.

Also, pressing control-shift-eject will turn off your iMac's display without putting the computer to sleep. It will save more energy than simply setting the background to black.
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 06:06 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,