Archive for April, 2008

Centering a Window Via AppleScript

John Siracusa recently lamented the loss of one of his classic OS add-ons; the ability to center the current window onscreen via a global key combo.

Well, the global key combo can be had in any number of ways, but here’s an AppleScript that’ll do it for you. It finds the screen size using the technique Craig Hockenberry showed to John Gruber, then finds the current frontmost window and resizes it. Saved as a Script into my Script Menu, it seems to work fine.


on run
	tell application "System Events"
		set fma to first process whose frontmost is true
	end tell

	tell application (name of fma)
		set fmwBounds to bounds of first window
	end tell

	tell application "Finder"
		set desktopBounds to bounds of window of desktop
	end tell

	set fmwWidth to (item 3 of fmwBounds) - (item 1 of fmwBounds)
	set fmwHeight to (item 4 of fmwBounds) - (item 2 of fmwBounds)

	set desktopWidth to (item 3 of desktopBounds) - (item 1 of desktopBounds)
	set desktopHeight to (item 4 of desktopBounds) - (item 2 of desktopBounds)

	set newX to (desktopWidth / 2) - (fmwWidth / 2)
	set newY to (desktopHeight / 2) - (fmwHeight / 2)

	set newBounds to {newX, newY, newX + fmwWidth, newY + fmwHeight}
	tell application (name of fma)
		set bounds of first window to newBounds
	end tell
end run

Daniel Jacob

Daniel Jacob:

Daniel Jacob

My nephew, aged 5 days. Congratulations, Fred!

Scenes From A Taco Bell

[Inside, Lunchtime. Two men in their sixties in "San Juan Capistrano Police Volunteer" uniforms sit at a table covered in empty wrappers. Another man, just as old, stands nearby.]

Non Volunteer Old Man: It’s been nice talkin’ to y’all. Say, who you voting for?

Old Man 1: Not Hillary.

Old Man 2 shakes his head and smiles.

Old Man 1: I’m voting for McCain. And let me tell you, I’m thinking about that. Thinking real hard.

These guys are there every Friday. Even if I didn’t like Taco Bell I’d go to overhear them.

Democratic Caucus on The Colbert Report

Senator Clinton’s appearance felt a little strained, Senator Obama’s appearance was kind o funny, but EdWørds was hands-down the best of the cameos. Better introduction, better content, and much, much funnier. It reminds me of Al Gore on SNL warning about attacking glaciers; surreal enough that you know they’re in on the joke, but real enough that it’s not preachy when it turns back to the real issue. It’s Al Franken’s “kidding on the square.”