Obtaining screen Resolution

Is there a way to obtain the screen resolution of the monitor in apple script, without opening the System preferences.

Is it possible using terminal ?


This may work:

{word 3 of (do shell script "defaults read /Library/Preferences/com.apple.windowserver | grep -w Width") as number, ¬
	word 3 of (do shell script "defaults read /Library/Preferences/com.apple.windowserver | grep -w Height") as number}

(as you see, you can use the Terminal)

Thats really great it worked!

Thanks a lot

Here’s a script that used to be on Apple’s GUI Scripting web page. If you have Mac OS X 10.3 (Panther) you can click on the link to open the script in your Script Editor, it also works in Jaguar if you are using the beta version of the Script Editor 2.0 v36

[This script was automatically tagged for color coded syntax by Script to Markup Code]

I just released a small bit of software using the “windowserver” file to determine screen size, and got a reply from an interational user saying the script couldn’t find the file. It must not be there on all systems.

Just fyi.


You can use Jon’s Commands scripting addition also.’

set screen_list to (screen list)
set first_screen to (item 1 of screen_list)
set screen_resolution to (screen size of first_screen)