I wanted to write a script that would open a Safari bookmark which is nested in a folder under the Bookmarks menu item. The path is thus: BookMarks (menu item) > Computers (folder below the bookmarks menu item) > Outpost.com (bookmark).
I wanted to use System Events because this is just a practice script: later I will want to write one that enters a user name and password that Safari’s Autofill will not, so that will require System Events as I understand things.
I was able to use System Events to open a Safari bookmark but not if the bookmark was nested inside a folder such as in the example above. Somebody showed me how write the script to open the Outpost.com bookmark. It looks like this:
tell application “System Events” to tell process “Safari”
click menu item “outpost.com” of menu ¬
“computers” of menu item ¬
“computers” of menu ¬
“Bookmarks” of menu bar item ¬
“Bookmarks” of menu bar 1
end tell
What I don’t understand is why “computers” appears twice, once as a “menu” and again as a “menu item” Likewise for "Bookmarks. Here is what I see using UI Inspector:
<AXApplication: “Safari”>
<AXMenuBarItem: “Bookmarks”>
<AXMenuItem: “Computers”>
<AXMenuItem: “Outpost.com”>
That doesn’t help me understand why “computers” and “bookmarks” appear twice. Can anybody tell me where I can find an explanation for this or offer one? Thanks much.
Model: G5 dual 2.7; Tiger
AppleScript: 2.1
Browser: Safari 412.5
Operating System: Mac OS X (10.4)