Mac How can I detect screen rotation on mac?

donggan123

macrumors newbie
Original poster
Nov 18, 2011
3
0
Is it possible to detect screen rotation? I'm woking on the touch screen driver on mac, so I want to know if the screen is rotated.

Any ideas? All help is appreciated! Regards
 

unixperience

macrumors regular
Jul 21, 2010
235
5
i dont know for sure but i assume you could do this applescript

screenWidth to word 3 of (do shell script "defaults read /Library/Preferences/com.apple.windowserver | grep -w Width") as number

set screenHeight to word 3 of (do shell script "defaults read /Library/Preferences/com.apple.windowserver | grep -w Height")

i got this from here Basically i think just quering the OS for screen size then say (sudo code)

if width > height
im rotated
else
im not
 

donggan123

macrumors newbie
Original poster
Nov 18, 2011
3
0
i dont know for sure but i assume you could do this applescript

screenWidth to word 3 of (do shell script "defaults read /Library/Preferences/com.apple.windowserver | grep -w Width") as number

set screenHeight to word 3 of (do shell script "defaults read /Library/Preferences/com.apple.windowserver | grep -w Height")

i got this from here Basically i think just quering the OS for screen size then say (sudo code)

if width > height
im rotated
else
im not
Thanks for your reply! This script can detect the screen rotated. But I can not determine whether it rotates left or right.

----------

I just tried it. It works just fine. Thanks very much!:D
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.