Noobie asks: How to reposition Internet Connect window on desktop?

Hi,

E/ time I open the app “Internet Connect” its window appears in a different position on my desktop than where I last left it. I would like it always to open in exactly the same position. Is that scriptable? Judging from similar posts I guess it just involves activating the app and specifying coordinates for the upper left corner of the window, but I’m too “noo” to pull it off. Any help greatly appreciated!

BTW in case you’re wondering I don’t think the size of the window is an issue here, just the position.

Model: PowerBook G4
AppleScript: 1.10.6
Browser: Safari 417.9.2
Operating System: Mac OS X (10.4)

Hi longjump

try this

tell application "Internet Connect"
	activate
	set bounds of window 1 to {1239, 1081, 1739, 1197}
end tell

or change “{1239, 1081, 1739, 1197}” to what ever fits your monitor

Thanks pidge1, that works great except for one thing. The size of the Internet Connect window varies depending on whether I’m connected, plus possibly other factors too. This means that sometimes the absolute window size in the script can cause the window to come out looking kinda screwy.

Is it possible to specify only the position of the window (say, maybe just the upper left corner) w/out specifying all four corners?

Perhaps something like this, longjump:

to |set position| for w to {x, y}
	set {l, t, r, b} to w's bounds
	set w's bounds to {x, y, x + r - l, y + b - t}
end |set position|

activate application "Internet Connect"
|set position| for application "Internet Connect"'s window 1 to {0, 22}

Kai, mucho thanko. That did it.

You’re welcome, longjump.

Of course, another way to achieve a similar effect would have been to use GUI Scripting:

activate application "Internet Connect"
tell application "System Events" to set position of window 1 of process "Internet Connect" to {0, 22}

However, since that relies on GUI Scripting being enabled, there’s no guarantee that it will necessarily work on a particular machine.

You could also use the technique suggested earlier to target any other window that has no position property - as long is it has a bounds property. (In this variation, I’ve also added a precautionary test for existence.)

to |set position| for w to {x, y}
	tell w to if exists then
		set {l, t, r, b} to bounds
		set bounds to {x, y, x + r - l, y + b - t}
	end if
end |set position|

activate application "TextEdit"
|set position| for window 1 of application "TextEdit" to {0, 22} (* modify position as required *)

Good stuff Kai
puts my effort to shame!!

cheers