Re: System Events scripting of Finder window
Re: System Events scripting of Finder window
- Subject: Re: System Events scripting of Finder window
- From: David Marshall <email@hidden>
- Date: Sat, 17 Mar 2007 20:03:23 -0400
On Mar 17, 2007 6:38:53 PM EDT, Doug McNutt noted:
It's interesting to note that "Arrange" is either menu item 5 or 6
depending on starting at 0 or 1 for the count from the top of the
GUI pull down menu. I see no way it can be 7, but it does work that
way in the script above.
It took me a long time to figure the menu item numbering out, but I
think it works this way: separators count as menu items, as do
context-specific variants of a given command. So, in the case in
question, "as Icons," "as List," and "as Columns" are menu items 1, 2
and 3; the separator is item 4; "Clean Up" and "Clean Up Selection"
are 5 and 6, and "Arrange" [Panther] / "Arrange By" [Tiger] is menu
item 7.
Although UIElementInspector sometimes makes the otherwise-inscrutable
into the barely scrutable, I also find that digging down through the
element tree a layer at a time via Script Editor and the Event Log
can be surprisingly revealing.
Just for amusement, here's a script which recreates Finder's View
menu and numbers each item (please excuse the lack of flush-left
formatting where the numbers go from 1 to 2 digits; chalk it up to
sheer laziness):
tell application "Finder" to activate
tell application "System Events"
tell process "Finder"
set theseItems to {}
set n to 1
repeat while n < 14
try
set thisItem to name of menu item n of menu 5 of menu bar 1
set end of theseItems to (n as text) & " " & thisItem
set n to n + 1
on error
set end of theseItems to (n as text) & " " & "-----------"
set n to n + 1
end try
end repeat
end tell
end tell
set AppleScript's text item delimiters to return
tell application "Finder"
display dialog theseItems as text
end tell
set AppleScript's text item delimiters to ""
- - - - -
Dave
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden