How can I detect screen rotation on mac?

Discussion in 'Mac Programming' started by donggan123, Nov 18, 2011.

  1. donggan123 macrumors newbie

    Joined:
    Nov 18, 2011
    #1
    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
     
  2. unixperience macrumors regular

    Joined:
    Jul 21, 2010
    #2
    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
     
  3. donggan123 thread starter macrumors newbie

    Joined:
    Nov 18, 2011
    #4
    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
     

Share This Page