Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

exscape

macrumors member
Original poster
Jul 29, 2008
57
0
Is this possible (without too much effort)? I don't care much about the language used, as I have at least a basic understanding of all the possible candidates here. (I'm assuming Cocoa APIs will be required.)

The program should, without any GUI if possible, find the Firefox window (if there are multiple, simply exit) and resize it to a pre-defined position (and width, and possibly height). Nothing more, nothing less. No arguments, no options, except those set at compile time.

Any advice on how to do this?
 

exscape

macrumors member
Original poster
Jul 29, 2008
57
0
AppleScript seems like a likely candidate.
Thanks! :)
That tiny hint pointed me to a guide on how to accomplish exactly this. Very simple, too:
Code:
tell application "Firefox"
	activate
	set the bounds of the first window to {0, 0, 1440, 600}
end tell

Edit: I ramped it up a little and made it preserve the window height, too.
Code:
tell application "Firefox"
	set b to the bounds of the first window
	set height to (item 4 of b) - (item 2 of b)
	
	set the bounds of the first window to {0, 0, 1440, height}
end tell
The item 4 minus item 2 is because, apparently, the list element aren't x, y, width, height as I expected, but rather the coordinates of each side of the window.
 

exscape

macrumors member
Original poster
Jul 29, 2008
57
0
For some reason I don't understand, this doesn't work anymore with Firefox, which seems to report its bounds as taking up the entire screen ((0,0,1440,900) here).
Here's my new version:

Code:
tell application "System Events"
	-- Set position (The menu bar will be taken care of automatically)
	set position of window 1 of process "Firefox" to {0, 0}
	
	-- Get the size, in the format {width, height}
	set height to item 2 of (get size of window 1 of process "Firefox")
	
	-- Finally, set the size
	set size of window 1 of process "Firefox" to {1440, height}
end tell
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.