Three noobish questions

I googled all evening and haven’t yet found anything useful… I hope these questions will be very easy to Applescript gurus here )

  1. Is there a way to get full height (or top left corner coordinates) of a window including its header (do not know the right term, the bar with close-minimize-maximize buttons and window title)? Seems that ‘bounds’ and ‘position’ of Window suite do not know about it.

  2. Is there a way to enable GUI scripting via Applescript?

  3. How can I get properties with spaces in names? For example,

tell application "Finder" to get position of Finder window "Macintosh HD"

works fine, and

tell application "Finder" to get has shadow of Finder window "Macintosh HD"

results in error, though, according to documentation, Window suite has ‘has shadow’ property.

Thanks in advance.

Hi and welcome

1.) in the case of the Finder if you want to have the (0,0) coordinate right below the menu bar, use


tell application "Finder"
	tell (get bounds of window 1) to set {x, y} to {its item 1, (its item 2) - 44}
end tell

in any other application use


tell application "iTunes"
	tell (get bounds of window 1) to set {x, y} to {its item 1, (its item 2) - 22}
end tell

2.)


tell application "System Events"
	set UI elements enabled to true
end tell

you have to enter the admin password

3.) Finder window of application “Finder” has no “has shadow” property

  1. Great thanks, it works )

  2. Aren’t “magic numbers” you have used sort of dangerous? I mean, window header can have other height, depending on user settings. I think, there have to be another way, something without hardcoding.

  3. The window has “has shadow” property, according to this page: http://developer.apple.com/documentation/AppleScript/Reference/StudioReference/sr3_app_suite/sr_app.html. Some properties described there I can get, some of them produce an error… Or am I looking in the wrong place?

Yes, the documentation is the AppleScript Studio Reference, you are dealing with plain AppleScript

I’d really like to know about the ‘magic numbers’ as well. Even if there’s no way for a window’s decoration panel to be something other than 22, that seems pretty sloppy, and who’s to say they won’t change it to 25 or something in OS XI?

Surely there’s a handy way to grab the title-bar size in actionscript, or at least calculate it from other sizes?