AppleScript how to get current display resolution?

dan picture dan · Dec 8, 2009 · Viewed 7.7k times · Source

I'm trying to get the current display resolution of both of my displays depending on where the mouse cursor is.

i.e. when the mouse cursor is on the first display I want to get the resolution of this display.

With a shell script I can get both resolutions:

set screenWidth to (do shell script "system_profiler SPDisplaysDataType | grep Resolution | awk '{print $2}'")

But I don't get which display is currently "active".

Any ideas?

Answer

Ronald Hofmann picture Ronald Hofmann · Oct 30, 2011

This does the trick:

tell application "Finder"
set screen_resolution to bounds of window of desktop
end tell