Copy and paste webpage URL and title

Help! I'm at a loss for what should be a simple Macro that will:

  1. Copy the URL and name of the webpage I'm currently viewing, in any browser [but if it must be browser-specific, then just in Chrome Version 78.0.3904.87 (Official Build) (64-bit)].

  2. Open a new tab in the browser with a particular URL (a Facebook Messenger conversation).

  3. Paste the webpage name, followed by the URL (on a separate line if possible) into the Messenger conversation as new text.

I have attached an image of the macro I created. All it does is make a New Front Browser Tab with URL. This is the error message:
Action timeout exceeded. Macro “Messenger Weblink to Scott” cancelled (while executing Copy to Named Clipboard “Web Page Title”).

I'm using:
Keyboard Maestro Version 9.0.3
MacOS Catalina 10.15.1, MacBook Pro 13"
Allow Javascript from Apple Events has a checkmark next to it

I'm guessing it's timing out because there's nothing for the "Copy to Named Clipboard" action to copy after opening the new tab. Regardless, I would recommend using variables for something like this instead of named clipboards, and including a pause after the "New Tab" action to let it finish loading before pasting the text. It's also definitely possible to include the URL on a separate line; in fact, you can combine the page's name and URL on two separate lines within a single variable to make it simpler:

@gglick has answered your basic questions, and his macro may be all you need.

I used this as an opportunity to build a more general purpose macro that should work with any target web page. I don't use Facebook (or its Messenger), so I could not test specifically for that case. But many web pages require some action to open and/or set focus to the text input area on that web page.

So, my macro allows for just that. It may be more complex than you need, but I hope it will satisfy a general use case. Feel free to ignore, or use parts of it as you need.

Please let us know if this meets your needs, or if you have further questions.

MACRO: Paste URL and Page Title into Another Web Page [Example]

Note that the macro uses this KM Forum as the target page for testing purposes.

Thank you! Your macro nearly worked, but didn't actually insert the LocalText. However, you gave me the direction I needed. I merely had to delete "Pause for 1 Second" and replace it with "Wait For Front Browser to Finish Loading." Here is a screenshot of my final macro:

1 Like

Wow! Thank you for posting this. While it's more than I need for this situation, it's quite valuable in helping me better understand how to create macros that perform similar actions. I'm still studying it, trying to understand all parts, and to think of use cases where I can implement it.

1 Like