Copy selected contents from webpage and copy that AND the URL into Scrivener?

I use Scrivener for my research. most of the items there are found on the web. Prior to using keyboardmaestro, I have done this manually by

  1. marking the content on the page, and copy it (command C)
  2. switch to Scrivener
  3. select new document and paste content there (command V)
  4. select the URL and copy it
  5. paste it into Scrivener in the field "Notes"

I have recorded these steps in Maestro, but the proces fails... probably / seemingly by the fact that "clipboard content" does not reflect the URL but keeps the first copy (of the page content).

I have then inserted in the start of my macro and once more before copying the URL, the Action: Delete current system clipboard, expecting a clean slate. But not so... then I have (without deep understanding) also inserted in the macro the commands that clears clipboard 1, 2 and 3.
No luck... but... to my amazement there is inserted som snippets I copy/pasted in word 8 hours ago, instead of the selected text and the URL

So I am looking for a deeper understanding of this macOS clipboard in combo with Maestro.

Hope someone can share som useful knowledge.

I use an iMac27"-5K with high Sierra 10.13.6.

Kind Regards,


1 Like

Hey GreyT,

What web browser are you using?


and I'll stay with that :slight_smile:

1 Like

Hey GreyT,

Safari is fine (and is quite scriptable).

This used to be available on the App-Store:

Clipboard Viewer

It is no longer (at least in the U.S. store).

Nevertheless – you can get a copy by downloading and installing Xcode.

Here's some other information about working with the clipboard:

Clipboard viewer for OS X that allows extracting the data in any available format

Finally – here's a macro that will let you copy text from Safari and run the macro to extract the HTML of the copied text from the system pasteboard (clipboard).

Safari -- Extract HTML Code from the Clipboard v1.00.kmmacros (6.1 KB)

Once you have the HTML, you can parse it for the link you want.


Woa thats a lot... but my concern is just to get the webadress, from the top of safari (as text sort of, not the tru URL) and I can get this simply by clicking + copy and the paste.
my headache comes from that the macro trained to do exactly this, will paste something different... and that different is mostly the text that was copied before from the webpage itself.
AND I cannot deduct where that text is kept (which clipboard).
So maybe the question is not so much with maestro more about those 'clipboards' and their persistent memories


Hey GreyT,

Okay, I seem to have misunderstood what you were doing.

But I must tell you that this:

Is not clear at all.

The Mac essentially has one clipboard – the system clipboard. All of Keyboard Maestro's named clipboards and clipboard history items are just data in a file/database.

To use them one has to run them through the system clipboard again.

It would be best if you post your macro, so we can see what's happening and test for ourselves.

How to Post Your Macro to the Forum

Are you using any Clipboard management utilities other than Keyboard Maestro?

What version of Keyboard Maestro are you using? And what version of macOS?


Sorry for non-articulate phrasing on URL etc.
Attached is a screenclip with an example of the link I need to copy. This goes fine when I stay in macOS, but not so much using maestro… due to the confusion about what to copy and WHERE is is stored

It will be solved, and just now I am greatly frustrated


Hi Palle,

If the only/main problem you have is with pasting the URL, you can just paste the %SafariURL% token and avoid the clipboard entirely:


BINGO … HEUREKA… that works… wauwwwww… I am so grateful for the feedback, and very satisfied, and… my mouse fingers will not get that tired anymore.

I simply added, by recording, the one mouseclick in the place I need theURL to go and then the Action “Insert Text", as your suggestion.




1 Like

Just to be clear.

The Clipboard is not avoided entirely in this case – it's just transparent to the user.

Once Gabe's macro is run the Clipboard contains the URL from the front page in Safari, because the System Clipboard is the only gateway by which paste can take place on macOS.

A potential pitfall in getting the %SafariURL% is that Apple has decided when an app is hidden then the index order of its windows is undefined. (Bad Apple!) – and this means that scripting a given window from a hidden app may produce very unexpected results.

Here's an augmented version of Gabe's macro that compensates if necessary for the window index problem and also purges the clipboard of the pasted URL (restoring what was on it before the paste).

Paste Safari URL from Frontmost Page-Tab.kmmacros (4.9 KB)

Now then – you expressed confusion about where things are stored.

Data is not generally stored unless the user stores it.

For instance – you could set a variable to the %SafariURL% token and use it again later: