Set bounds of window gets inverted

I have a very simple script to set the bounds of every finder window. It works great, most of the time. Sometimes however, instead of producing wide and short windows, it will change everything to tall and thin windows. The script doesn’t change, just the way that the finder processes it. Does anyone have any ideas why? It seems like it only happens after significant uptime, and a restart always cures the behaviour. It’s being run on a G5 tower running 10.4 in a newspaper production environment


tell application "Finder"
	set bounds of every window to {119, 119, 900, 544}
	set the current view of every Finder window to list view
end tell

On an old G5 with the same OS 10.4 I had this issue never did find the cause. Drove me nuts sorry I can’t help.

Next time when it is corrupted ask the finder’s desktop size. If this doesn’t match the size of the actual screen resolution you have the same bug as in 10.3. The problem can be solved by getting Finder’s desktop size and set the bounds of the window relative to the Finder’s desktop size.

Interesting. I hadn’t heard of that bug. I’ll check it out. Thanks.

Hmm, no good. Using this code:

{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}

the script returned the correct size for my desktop, 1280x1024. I guess I’ll just have to keep restarting and hope that when we switch to our new iMacs and 10.6, the problem will go away.

Yvan, your reply seems to have been lost in the server glitch last week. I’m curious to know what you said.

I wrote that


tell application "Finder"
	bounds of desktop's window
--> {0, 0, 1920, 1080}
end tell

would return the infos in the order which is used for other window.
This way, you may compare with the ones returned by the Shell Script codes.

I can’t test because on my machine, the Shell Script return :
error “2011-03-21 18:54:41.642 defaults[1271:903]
Domain com.apple.windowserver does not exist” number 1

Yvan KOENIG (VALLAURIS, France) lundi 21 mars 2011 18:57:32

Merci, Yvan
That currently returns {-1280, 0, 1280, 1024}, which is correct as I have a secondary monitor on the left, with both screens running at 1280x1024. I will save that and see what comes up next time my bug pops up.

Ok, still makes no sense.

tell application "Finder"
	set bounds of every window to {119, 119, 900, 544}
	set the current view of every Finder window to list view
end tell

returns:

tell application "Finder"
	set bounds of every window to {119, 119, 900, 544}
		{}
	set current view of every Finder window to list view
		{}
end tell

with the bounds obviously wrong.

tell application "Finder"
	bounds of window 1
end tell

returns:

tell application "Finder"
	get bounds of window 1
		{120, 120, 544, 900}
end tell

So when it’s reading the bounds, it knows them correctly, but when setting them, it inverts them, with no indication that it is actually inverting them. I give up. It’s just going to be restarts until our iMacs with 10.6 are ready.