Detecting a window's tool bar

The title says it all. Preview doesn’t seem to have a window property showing whether a tool bar is displayed. I thought to keystroke ‘command b’, get window size, keystroke ‘command b’ again, compare and then leave it or revert, but that doesn’t seem to work with Preview (which isn’t scriptable). The drawer isn’t counted in size, so that’s not an issue. There is a 'TB is shown property of com.apple.preview.plist, but that seems a bit much to go after.

tell application "System Events" to tell process "Preview"
	activate
	keystroke "b" using command down
end tell
 -- fails

I’m afraid activate won’t persuade an application process, Adam. (A slip of the fingers, methinks.)

tell application "System Events" to tell process "Preview"
	set frontmost to true
	keystroke "b" using command down
end tell

This might suit your purposes better (though you might need to change “Hide Toolbar” to “Show Toolbar”, depending on your aim):

tell application "System Events" to tell application process "Preview"
	set frontmost to true
	tell menu item "Hide Toolbar" of menu "View" of menu bar item "View" of menu bar 1 to if exists then click
end tell

Thanks, Kai. Not a slip of the fingers either, I’m afraid :/, it’s never been entirely clear to me when each of those (activate vs frontmost) apply.