You are not logged in.
I need a reliable way to determine the desktop size in order to drop an item at specific coordinates. I can't find any hooks at all.
Offline
Try something like this, ddoscher. (May give spurious results with more than one monitor).
Applescript:
tell application "Finder" to set desktop_size to items -2 thru end of (get bounds of desktop's window)
Last edited by kai (2006-02-19 03:16:39 pm)
Offline
an alternative way to determine the size of first and second monitor could be:
Applescript:
set myResolution to (do shell script "system_profiler SPDisplaysDataType | grep Resolution | awk '{print $2, $4}'")
result looks like this with two monitors connected:
"1152 768
1024 768"
Offline
And if you want to know the location the second screen origin with respect to the first, see this Code Exchange item which will also return a bunch of other data about the screens
Offline
One more method, just for good measure (primary monitor):
Applescript:
tell application "System Events" to tell property list item 1 of property list item 1 of property list item "DisplaySets" of property list file "/Library/Preferences/com.apple.windowserver.plist" to set screen_size to {(value of property list item "Width") div 1, (value of property list item "Height") div 1}
(In terms of speed, however, the Finder approach tops anything else.)
Offline
Can you position items on the desktop in Tiger?
Offline
Sure, kel (within certain bounds):
Applescript:
tell application "Finder" to set desktop position of (make new folder with properties {name:"test folder"}) to {40, 50}
Last edited by kai (2006-02-19 10:28:55 pm)
Offline
Hi Kai,
Thanks for the info.
gl,
Offline
Adam Bell wrote:
And if you want to know the location the second screen origin with respect to the first, see this Code Exchange item which will also return a bunch of other data about the screens
Hi Adam,
your code did not succeed with my configuration:
OS X 10.4.4/AppleScript 1.10.3
Language: German
2 Screens connected (Powerbook internal 1152 x 768 + external 1024 x 768)
Error message (translated to english):
AppleScript Error
„word 33 of "OriginX = 0; OriginY = 0; -- OriginX = -1024; OriginY = 57; Height = 768; Height = 768; Width = 1152; Width = 1024; DisplayLayoutToRight = 0; tilesize = 18;"“ could not be read.
D.
Last edited by Dominik (2006-02-20 03:35:46 am)
Offline
Oof. What does this return on your system?
Applescript:
words of (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`")
Offline
Oof. What does this return on your system?
Hi Adam,
I found out: my com.apple.dock had no key "orientation"
My Dock is - and was always - on the bottom of the page. After switching the position to 'left' and back to 'bottom' your script ran without an error. My guess: The key is only created after a first position change.
But there might be an other little problem with the script:
After my external monitor is disconnected and 'System Preferences' -> 'Monitors' is updated, the script still reports my external screen. Maybe the defaults are only updated with a reboot?
I played a little with your code and made an attempt to simplify the shell part a little ...
try this and tell me what you think - do you think it could work? I am not yet 100% sure about the order of those keys:
Applescript:
set olddelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to space
-- I could not use every word of ... since this produces an error with negative values (it made '1024' of '-1024' (X-position of my external screen)
set details_new to every text item of (do shell script "echo `defaults read /Library/Preferences/com.apple.windowserver | grep -w -m9 --regexp={DisplayLayoutToRight,OriginX,OriginY,Height,Width} | awk '{print $3}' | tr \";\" \" \"` `defaults read com.apple.dock orientation` `defaults read com.apple.dock tilesize`")
set AppleScript's text item delimiters to olddelims
Daisy
Offline