Struggling to Select a "Bookmark" Table Row in VLC's Bookmark Window with UI-Scripting

I am trying to achieve the following with a KM Macro:

In application VLC,

  1. open the "Bookmarks" floating window (CMD-B)
  2. create new entry (Click button "Add")
  3. in the list of existing entries, navigate to the new entry
  4. edit it (Click button "Edit")

I am struggling with step 3.
I tried to select the table with the following Applescript

tell application "System Events"
	tell process "VLC"
		select row 1 of table 1 of scroll area 1 of window "Bookmarks" of application process "VLC"
	end tell
end tell

This code was created by UI Browser. However, the Macro fails with an Applescript error (which shows up truncated as a Notification).

How do I see the complete error message?

I would be grateful for any assistance you can give me regarding this!

can you share your macro to see what you got so far

Hey @WorkflowsGuy,

You can drag down from the bottom of the Notification Center message.

You can also open the Keyboard Maestro Engine log.

See “Open Logs Folder” in the Help menu of the Keyboard Maestro Editor.

Better yet – never prototype AppleScripts or other scripts in a Keyboard Maestro action.

Use the Applescript Editor.app or Script Debugger Lite which is 20 times better and free.

For shell scripts use the Terminal or BBEdit or another script runner that has proper syntax highlighting and checking – and a more visible font.

Once you have developed your code in a proper environment – then copy it into your Keyboard Maestro macro.

Please also tell us what version of the software you're using and on which version of macOS.

This is VLC 3.0.11.1 on macOS 10.12.6 Sierra, and it works quite quickly on my old hardware.

This was a pita, because the bookmarks window is a floating window that vanishes when you switch out of the VLC context. So – at least on my system – UI Browser can't see it long enough to grab values out of the browser. Thus I had to do a fair amount of detective work by hand.

-Chris

--------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2020/12/22 12:09
# dMod: 2020/12/22 12:09 
# Appl: VLC, System Events
# Task: Make a New Named Bookmark in the Bookmarks Window
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @System_Events, @VLC, @Bookmark
--------------------------------------------------------

tell application "System Events"
   
   tell application process "VLC"
      
      if name of front window ≠ "Bookmarks" then
         
         tell menu bar 1
            tell menu bar item "Window"
               tell menu 1
                  tell menu item "Bookmarks..."
                     perform action "AXPress"
                  end tell
               end tell
            end tell
         end tell
         
         set bailOutValue to 0
         repeat until (get name of front window) = "Bookmarks"
            if bailOutValue > 10 then error "Bookmarks Window Failed to Open!"
            set bailOutValue to bailOutValue + 1
            delay 0.1
         end repeat
         
      end if
      
      tell window "Bookmarks"
         
         tell button "Add"
            perform action "AXPress"
         end tell
         
         tell table 1 of scroll area 1
            tell last row
               set selected to true
            end tell
         end tell
         
         tell button "Edit"
            perform action "AXPress"
         end tell
         
         tell sheet 1
            tell text field 1
               set its value to "ImABookmark"
               perform action "AXConfirm"
            end tell
            tell button "OK"
               perform action "AXPress"
            end tell
         end tell
         
      end tell
      
   end tell
   
end tell

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

You can also open the Keyboard Maestro Engine log

Thank you everybody who responded. It took my some time to process the answers...

The log message was

2020-12-25 10:15:04 Execute an AppleScript failed with script error: text-script:332:425:

2020-12-25 10:15:04 Execute an AppleScript failed with script error: text-script:332:425:. Macro “Lesezeichenfenster öffnen und neuen Eintrag hinzufügen” cancelled (while executing Execute AppleScript).

Not very helpful in diagnosing an issue.

@ccstone: Thank you for your advice on how to develop an AppleScript. Somehow "Script Debugger" vanished from my radar. I just wished that this valuable information was available in the KM wiki or FAQ.

And an even bigger "Thank you" for taking the time to provide the AppleScript. It is actually much simpler to put the complete logic inside the AppleScript and just bind it to a command with KM.
I now have a working solution to easily create bookmarks in VLC 3.0.11.1 on macOS 10.13.6.

Regarding capturing the contents of floating windows with UI Browser: did you see that if using CMD as modifier when clicking, the floating window stays on screen (it's still a bit tricky, though)?

Best Regards,
Guy

Yes, I'm a long time UI Browser user.

For some reason on my old Sierra system freezing the floating window would not provide a proper report.

I haven't fussed to Bill Cheeseman about it yet, but I will eventually after investigating some more.

-Chris