Can't Get FrontBrowserTitle to Work

Happy new year to everyone.

I'm attempting to make a simple macro that grabs the Title & URL of the front browser and saves it to clipboard in markdown format.

This is what I'm doing currently. Setting clipboard to the Front Browser tokens for title and URL, but Title comes back empty.

I'm using Vivaldi:

Vivaldi 5.0.2497.32 (Stable channel) (arm64)
Revision 4891cb2a30270ebb895cf22eb99642090bde0046
OS macOS Version 11.6 (Build 20G165)
JavaScript V8 9.6.180.21
User Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.113 Safari/537.36

And this is my Mac info:

image

I'm sure there's something obvious that I'm not doing here.

Thanks,

Matt

1 Like

This is the output when I run the macro on this page:

[](https://forum.keyboardmaestro.com/t/cant-get-frontbrowsertitle-to-work/25789)

Make sure to allow KM and KM engine to run scripts.

Check in System Preferences > Privacy that both are allowed.
Also check in Vivialdi that it can receive/allow AppleScript events

btw there's already a KM macro that makes this

3 Likes

Thank you, it was the Vivaldi setting.

It's under Preferences > Privacy for anyone else that's wondering.

image

4 Likes

I can't get this same macro to run in Safari to save my life. I downloaded someone's working macros to use on Roam Research, so they've been vetted. Keyboard Maestro says the %FrontBrowserTitle% is empty. I've tried switching it to the SafariTitle = no luck. I've made sure JavaScripts are enabled and I've restarted my computer, Keyboard Maestro, etc. I'm running Mac OS Monterey. Help! Thanks.

Is this an Electron app?

Update: by Googling I got Allow Javascript from Apple Events to work with Monterey, and my %FrontBrowserTitle% field is no longer empty. However, I cannot get the data to paste into Roam. I've looked at the Creating Roam Templates doc but it's not helpful, and I'm currently searching on YouTube, but I'm stuck. Thanks

This is what I get from Interactive Help:
The macro “Roam Link” has fired 2 times.

Since the macro was triggered, you know that it is running the actions. If you are still not getting the results you want, you need to look at the actions you are using. Some common issues you might run in to include:

  • Is the target application ready to receive the events?
  • Do you need to add a Pause action to wait for the system to be ready?
  • If you are using a Click Mouse action, turn off the Restore Mouse Location flag and verify the mouse is going to the expected location.
  • If you are using a script action, make sure you are displaying the results, including any errors.

If you are still having troubles, post your question in the Keyboard Maestro Forum.

RoamResearch

Can't manually paste, or can't paste using a KM macro? If the latter, it'll help if you upload the macro so we can see what's happening -- How to Post/Upload your Macros and Scripts.

Thank you for your help. Ok, I followed the directions to upload as a Reply to Same Topic, and this is what I have to paste :. I hope this works.

Roam Link Macro (v10.1.1)

Roam Link.kmmacros (4.5 KB)

If all you want to do is set the System Clipboard to a Markdown link using the front browser's currently active page, then you only need:

Make Markdown Link.kmmacros (1.5 KB)

Image

You can then manually ⌘V to paste into Roam. You could script this further by including a "Paste" action etc, but what you need will depend on your workflow -- "I've already found the web page I want, Roam is active and I have the insertion point in the right place -- paste in the link" is different to "I'm in my browser and want to add the current page to the end of the Roam document My Links".

But the great thing about KM is that you can start with something simple like the above, get it working, find the way to use it that suits you, and easily add actions to make that happen.

The purpose of the macro is correct for what I want. I want to capture both the front page URL - and the URL document title - without having to manually position the insertion point. I’m trying to capture the reference data for research, so I need both. So how to make this macro work for that purpose? The macro was in a file I downloaded from a web article about Evergreens/Zettlekasten by Maggie Appleton, and it works for her research. The macro runs, the problem issue is with my Apple system, it doesn’t paste into the destination site, my Roam Research page. How to fix this? There is something wrong at the end of the macro.

Appreciate the help!

You misunderstand.

In the macro you posted the first nine actions are all concerned with collecting the front browser window title and URL and creating a Markdown link. All nine can be replaced with the single action I posted, which is literally:

"Set the clipboard to a [, then the front browser window's title, then a ] and a (, then the front browser window's URL, then a )."

Running it when this page is active gets me:

[Can't get FrontBrowserTitle to work - Questions & Suggestions - Keyboard Maestro Discourse](https://forum.keyboardmaestro.com/t/cant-get-frontbrowsertitle-to-work/25789/12)

...which should be exactly what you need. And you can run it without leaving Roam.

You finish your macro with a Notification. Great, you can see what the clipboard is set to. But at no point in your macro is there a "Paste" action -- so your text stays on the clipboard. You could manually paste the text into Roam, you could add a "Paste" action, or a "Type a Keystroke" action with ⌘V. Which you choose will depend on your workflow and what Roam will accept -- so try some things and see what works for you and the way you like to do things.

Oohhh. Got it! It works. I added a Paste from Named Clipboard action as opposed to messing with the rest of the macro, or adding an extra keystroke, but I may revisit your sound advice and simplify. Thanks alot for solving my problem.

1 Like