Why is addressable screen space > screen resolution

G’day

I’ve written a mad method of getting a screens resolution, but it returns a Y value 22 pixels more than the screens supposed resolution, on a 23" LCD monitor. Why, is what I’d like to know? :stuck_out_tongue:



-- Screen Sizer

--- Not Bloody Copyright
-- 2006
-- 'Rough as Guts Software'
-- By Santa

global ReturnIconsToPosition
set ReturnIconsToPosition to {}
global thelist
global MaxX
global MaxY
set MaxX to 0
set MaxY to 0


my SavePositions()
my MovePositions()
my ReplacePositions()

display dialog "Your monitor has an addressable desktop of " & MaxX & " by " & MaxY buttons "That was easy."

on SavePositions()
	tell application "Finder"
		try
			select every item of the desktop
			set thelist to (selection as list)
			if number of items of thelist = 0 then
				display dialog "I need an icon to work." buttons {"Cancel"}
				quit me
			end if
			set end of ReturnIconsToPosition to desktop position of item 1 of thelist
			close window "Desktop"
		end try
	end tell
end SavePositions

on MovePositions()
	tell application "Finder"
		try
			set x to 0
			set distribute to item 1 of thelist
			set temp to {780, 480}
			set the desktop position of distribute to temp
			set newMaxX to 781
			set newMaxY to 481
			set increment to 10
			repeat while increment ≥ 1
				repeat
					if newMaxX > MaxX then
						set MaxX to newMaxX
						set item 1 of temp to (item 1 of temp) + increment
					else
						set item 1 of temp to (item 1 of temp) - increment
						exit repeat
					end if
					set the desktop position of distribute to temp
					
					set NewPosition to desktop position of distribute
					set newMaxX to item 1 of NewPosition
				end repeat
				set increment to increment - 1
				set MaxX to MaxX - increment
			end repeat
			set increment to 10
			repeat while increment ≥ 1
				repeat
					if newMaxY > MaxY then
						set MaxY to newMaxY
						set item 2 of temp to (item 2 of temp) + increment
					else
						set item 2 of temp to (item 2 of temp) - increment
						exit repeat
					end if
					set the desktop position of distribute to temp
					
					set NewPosition to desktop position of distribute
					set newMaxY to item 2 of NewPosition
				end repeat
				set increment to increment - 1
				set MaxY to MaxY - increment
			end repeat
		end try
	end tell
end MovePositions

on ReplacePositions()
	tell application "Finder"
		try
			set desktop position of item 1 of thelist to item 1 of ReturnIconsToPosition
		end try
	end tell
end ReplacePositions

Model: G5 1.8 GHz
AppleScript: 2.1.1
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

22 pixels? Sounds like your script - which, admittedly, I have barely looked at - doesn’t properly account for the menu bar.

For what it’s worth, I use this (from http://bbs.applescript.net/viewtopic.php?id=14236) to figure out the resolution


tell application "Finder" to set x to desktop's window's bounds

--returns {0, 0, 1680, 1050} for my 17" screen

G’day Capitalj

That’s my point. It’s easy to get the bounds, but icons can be set outside of the bottom on my monitor.

It’s not the script as far as I know, cause the same routine works for the X axis exactly as it should.

If I were to try and account for the menu bar, wouldn’t the returned value be less? Does 0.0 refer to the top left of the menu, or top left of the screen?

Why can icons be set below the bottom bound, and not the right?

Regards

Santa

Ah! I just found this on the link you posted Capitalj, and you were right, the menu bar seems to be 22 pixels, which means 0,0 for icons must be the top left of the menu bar, not the screen real estate.

That in turn means my script is correct, the space available vertically is 22 pixels larger than the bounds indicate.

Thanks for the link. :slight_smile:

Santa


{word 3 of (do shell script "defaults read /Library/Preferences/com.apple.windowserver | grep -w Width") as number, ¬
	(word 3 of (do shell script "defaults read /Library/Preferences/com.apple.windowserver | grep -w Height") as number) - 22}

I’m not sure that’s right.

Your script returns a resolution of 1680 x 1072 for my screen, but I can’t figure out why. Everything else says it’s only 1680 x 1050 (including the menu bar.) I even measured my desktop with Free Ruler (http://www.versiontracker.com/dyn/moreinfo/macosx/13607) to be sure.:smiley:

I give up.:stuck_out_tongue: G’night.