Tuesday, February 9, 2010

#1 2005-12-28 09:19:18 am

Adam Bell
Administrator
From: Nova Scotia, Canada
Registered: 2005-10-04
Posts: 4175

Exploring Dual Screens

In an effort to locate things on my dual-screen setup without shoving them up against the menu bar or under the dock on my primary screen, I put this together. It returns nearly everything you might want to know about dual screens - errors if you have only one [This was fixed to allow a primary screen on either port of a dual-screen card and the menu bar to be on either screen - thanks to Rick Smykla for pointing out the flaws and testing].

Applescript:

to GetScreenParameters()
   tell (do shell script " defaults read /Library/Preferences/com.apple.windowserver | grep -w -m 2 Unit") to if word 3 = word 6 then return display dialog "There is only one screen attached to this computer!" buttons {"Oops"} default button 1 giving up after 5 with icon 2
   tell (do shell script "echo `defaults read /Library/Preferences/com.apple.windowserver | grep -wA 1 -m 2 OriginX``defaults read /Library/Preferences/com.apple.windowserver | grep -w -m 2 Height``defaults read /Library/Preferences/com.apple.windowserver | grep -w -m 2 Width``defaults read /Library/Preferences/com.apple.windowserver | grep DisplayLayoutToRight``defaults read com.apple.dock | grep orientation``defaults read com.apple.dock | grep tilesize`") to set details to {word 3, word 6, word 9, word 12, word 15, word 18, word 21, word 24, word 27, word 30, word 33}
   
   --> Origin1 x, y; Origin2 x, y; Height 1, 2; Width 1, 2; DisplayLayout 1 = Right; DockPosition 0 = Left; DockSize; Extent x, y. The screen with origin 0, 0 has the menu bar, or if Display2toRight = 1, then the menu bar is on the left.
   
   repeat with anItem in details -- not really necessary, but I wanted numbers.
       try
           set contents of anItem to contents of anItem as number
       end try
   end repeat
   
   tell application "Finder" to tell (bounds of desktop's window) as list to set details to details & {(item 3) - (item 1), (item 4) - (item 2)}
   tell details to return {OriginPrimaryX:item 1, OriginPrimaryY:item 2, Origin2X:item 3, Origin2Y:item 4, HeightPrimary:item 5, Height2:item 6, WidthPrimary:item 7, Width2:item 8, Display2toRight:item 9, DockPosition:item 10, DockSize:item 11, WidthDesk:item 12, HeightDesk:item 13}
end GetScreenParameters

GetScreenParameters()
--> {OriginPrimaryX:0, OriginPrimaryY:0, Origin2X:1152, Origin2Y:156, HeightPrimary:870, Height2:768, WidthPrimary:1152, Width2:1024, Display2toRight:1, DockPosition:"left", DockSize:36, WidthDesk:2176, HeightDesk:924}


Scripts are tested on a PowerMac dual-core G5/2.3 running OS X 10.5.8 or MacBook Pro Intel Core 2 Duo running OS X 10.6.2

Filed under: Finder

Offline

 

#2 2006-05-12 11:18:25 pm

beowulf
Member
From: San Jose, CA
Registered: 2006-05-12
Posts: 2

Re: Exploring Dual Screens

Very cool function. Do you know of any way to set the desktop picture of the secondary display?

Thanks.


Dave
____________________________
"Imagination is more important than knowledge." -- Albert Einstein

Offline

 

#3 2007-03-26 01:30:17 pm

kevincody1964
Member
Registered: 2003-11-14
Posts: 8

Re: Exploring Dual Screens

can you get the desktop to be the itunes screensaver?

Just asking.

Kc

Offline

 

#4 2007-04-14 12:11:49 pm

regulus6633
Member
From: Lexington Park, MD
Registered: 2006-11-01
Posts: 1124

Re: Exploring Dual Screens

Hi Adam, I just posted a similar script to code exchange and then I came across your script. I sure wish I would have found your script before I went through the trouble of creating mine from scratch. We took very similar approaches. You can see mine here: http://bbs.applescript.net/viewtopic.ph … 207#p79207

Anyway, as I was looking at my script and comparing it to yours I found an error in your script. I only noticed it because when testing my script I stumbled across a tricky part. I found that when getting the values from the plist file by using "word 3" (for example) that a negative sign is dropped (if there are any negative signs). So if you have your second display situated above or to the left of your main display, then either the OriginX or OriginY values for the second display will have a negative value. I had to format the origin values specially (not using "words" to coerce to a list) to retain the negative value. Your script displays those values as positive numbers.

I just thought you'd like to know.

Offline

 

#5 2007-04-25 12:55:43 pm

Adam Bell
Administrator
From: Nova Scotia, Canada
Registered: 2005-10-04
Posts: 4175

Re: Exploring Dual Screens

Hi, Reg;

Just back from 2 weeks away. Thanks for the heads up, but one of the returned values is "Display2toRight" where 1 is true and 0 is false. Did that not work for you?


Scripts are tested on a PowerMac dual-core G5/2.3 running OS X 10.5.8 or MacBook Pro Intel Core 2 Duo running OS X 10.6.2

Offline

 

Board footer

Powered by FluxBB

[ Generated in 0.285 seconds, 11 queries executed ]

RSS (new topics) RSS (active topics)