Open a Specific Safari Bookmark Folder in New Tabs?

Hi All,

This maybe trivial but couldn't find a solution Googling.

So let's say I have a bookmark folder called q9 I want to bind a key with keyboard maestro to launch all the bookmarks in that folder in new tabs.

Any clue how this can be done? I tried AppleScript example I found but none worked (I'm using the latest macOS Monterey and Safari 15).

Best

Z

Okay – found an Applescript way for whoever is interested:

set bookmarksFolder to "Q9"

tell application "Safari" to activate

delay 1

tell application "System Events" to ¬
	click menu item "Open in New Tabs" of ¬
		menu 1 of ¬
		menu item bookmarksFolder of ¬
		menu 1 of ¬
		menu bar item "Bookmarks" of ¬
		menu bar 1 of ¬
		application process "Safari"

Out of curiosity wonder if there is a native Keyboard Maestro way to do so.  :slight_smile:

1 Like

Any reason a Select or Show a Menu Item action wouldn't work?

Example Macro.kmmacros (1.5 KB)

Hey Z,

Nyet, and da – as @gglick has demonstrated.

The common Select or Show a Menu Item action works fine for this.

No – in that Keyboard Maestro has no Safari-specific functions to do any of that – they are all AppleScript under-the-hood anyway.

Here's a way to open a toolbar button for type-select.

--------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2021/11/15 14:42
# dMod: 2021/11/15 14:42 
# Appl: Safari, System Events
# Task: Open a Toolbar Menu To Make Type-Select Available.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Safari, @System_Events, @Open, @Toolbar, @Menu, @Type-Select
# Test: Tested on macOS 10.14.6 Mojave with Safari 14.1.2 (14611.3.10.1.5).
# Vers: 1.00
--------------------------------------------------------

ignoring application responses
   tell application "System Events"
      tell application process "Safari"
         set its frontmost to true
         tell (first window whose subrole is "AXStandardWindow")
            tell group 2
               tell menu button "QK"
                  perform action "AXShowMenu"
               end tell
            end tell
         end tell
      end tell
   end tell
end ignoring

--------------------------------------------------------

I also regularly make use of a "front-browser" macro that opens the bookmark menu for type-select and selects the first menu starting with the letter “A” – in my case for “Admin”.

Menu ⇢ Bookmarks.kmmacros (5.7 KB)
Keyboard Maestro Export

I realize these don't perform the task you asked about, but they are sufficiently related to put in this thread.

-Chris

Thx guys!

@ccstone, wondering in Applescript how does one define a sub folder? I.e. if I have a folder name Quest in the favorites bookmark folder how do I refer to this in Applescript?

This doesn't seem to work.

set bookmarksFolder to "Favorites/Quest"

Thx guys.

Z

Hey Z,

Here's the basic structure of a 3rd tier item.

-Chris

--------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2021/11/16 08:18
# dMod: 2021/11/16 08:18 
# Appl: Safari, System Events
# Task: Select Third Tier Menu in The Bookmarks Menu.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Safari, @System_Events, @Select, @Bookmarks, @Menu
--------------------------------------------------------

tell application "System Events"
   tell application process "Safari"
      set frontmost to true
      tell menu bar 1
         tell menu bar item "Bookmarks"
            perform action "AXPress"
            tell menu 1
               tell menu item "a_Admin"
                  perform action "AXPress"
                  tell menu 1
                     tell menu item "Login"
                        perform action "AXPress"
                     end tell
                  end tell
               end tell
            end tell
         end tell
      end tell
   end tell
end tell

--------------------------------------------------------

super thx!!

Z