Info

Hi, I'm David Askew

I build things

Homepage

Contact Me

About

Open Source

Display Helpers

Not too long ago I purchased a new Macbook Pro. This laptop is, by far, the best laptop I have ever owned. There is one caveat though : The “Retina” screen makes my eyes really tired with extended use. It has been necessary to use external monitors after about 6-8 hours of looking at the built-in display. Problem solved right? Well, not exactly …

After several days of doing this my eyes began to feel better. However, it is clear to me that OSX doesn’t handle multiple monitors, interal or external, as fluidly as it could. I found myself writing applescript again. Below I’ve listed a few code snipits you may find useful.

Problem, how do I tell how many displays I have connected?

1
2
3
tell application "Image Events"
  return count displays
end tell

Open in Script Editor

How do I make a window [un]hidden / [in]visible?

1
2
3
4
tell application "System Events"
  set visible of every process whose visible is false and name is "iTunes" to true
  set visible of every process whose visible is false and name is "Spotify" to true
end tell

Open in Script Editor