Tuesday, March 23, 2010

Mac terminal 또는 AppleScript에서 Screen Resolution 알아내는 방법

다음을 터미널에서 실행하면, width와 height를 각각 얻어낸다.
system_profiler SPDisplaysDataType | awk '/Resolution/{print $2}'
system_profiler SPDisplaysDataType | awk '/Resolution/{print $4}'
애플스크립트에서는 다음과 같이 하면 된다.
on myGetScreenResolutionW()
return (do shell script "system_profiler SPDisplaysDataType | awk '/Resolution/{print $2}'") as integer
end myGetScreenResolutionW

on myGetScreenResolutionH()
return (do shell script "system_profiler SPDisplaysDataType | awk '/Resolution/{print $4}'") as integer
end myGetScreenResolutionH

No comments:

Post a Comment