How do I get a link over which my mouse cursor hovers?

I am trying to automate downloading of a url over which my mouse cursor hovers. I need to copy the url of the link over which my mouse hovers without left-clicking it and then use the copied link to create a new download in my download manager, “Progressive downloader”.
How do I go about it?

  • Right click at 0,0 relative to the current mouse location
  • Pause for the menu to appear
  • Insert Text by Typing “Copy Link%Return%”
  • Open URL “%CurrentClipboard” with desired application

<img src="/uploads/default/1045/497ff4a464f9664e.png" width=“525” height=“352”

After several episodes of trial and error, I was able to get it to work using the workflow you pasted. However, I had to insert pauses between the various actions to allow for the copy action and for the download application to become the active app. It is working but I am hoping it can be further fine-tuned.

Thanks a million.

Hey Mirizzi,

This is a trifle tricky, because it depends upon the URL showing in Safari’s Status Bar, and websites can do more than show the URL of the link you’re hovering over.

This runs from an ‘Execute AppleScript’ Action.


Edit: Script updated 2015/05/16 to make the regex more comprehensive.

# Auth: Christopher Stone
# dCre: 2015/05/14 13:55
# dMod: 2015/05/16 00:17
# Appl: Progressive Downloader, Safari, System Events
# Task: Download the item the mouse is hovering on.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Progressive_Downloader, @Safari, @System_Events, @Download
#     : @Mouse, @Hover

set _destination to path to downloads folder

tell application "Safari"
  tell front document
    set _referer to its URL
  end tell
end tell

tell application "System Events"
  if quit delay ≠ 0 then set quit delay to 0
  tell application process "Safari"
    # set frontmost to true
    tell front window
      set _url to value of static text of group 2
      if class of _url is list and length of _url = 1 then set _url to item 1 of _url
    end tell
  end tell
end tell

if _url contains "http:" then
  set _url to do shell script "perl -wlne 'if ( m!https?://[^[:blank:]”'\"'\"'\"]+!i ) { print $& }' <<< " & quoted form of _url
  if _url starts with "http" then
    progressiveDownloader(_referer, {_url}, _destination)
  end if
end if

on progressiveDownloader(_referer, _linkList, _destination)
  tell application "Progressive Downloader"
    if not running then run
    repeat with i in _linkList
      set _task to make new task
      tell _task
        set address to i
        set referer to _referer
        set destination to _destination
      end tell
    end repeat
    if (count of tasks) > 0 then
      # resume _task
      error "No Tasks in Progressive Downloader!"
    end if
  end tell
end progressiveDownloader

I tried it using an online youtube downloader but it did not work. I tried to download the 360p video from this page, .

Hey Mirizzi,

If you can’t paste the link into Progressive Downloader and have it work then the script can’t do any better.

Video links tend to be rather tricky.


I can copy and paste the link into Progressive Downloader and it downloads the file with no issues.

Hey Mirizzi,

Okay. It wasn’t clear to me what URL you were trying to download, until I looked at the page for the third time.

This is the evil beastie we glean from Safari’s Status line:

Go to “”

Some sneaky person put the link in smart-quotes, and I didn’t account for them in the regex of the first script.

Here’s what we want to extract:

I have updated the original script in the original post — the main change being this line:

set _url to do shell script "perl -wlne 'if ( m!https?://[^[:blank:]”'\"'\"'\"]+!i ) { print $& }' <<< " & quoted form of _url

I would much rather use the Satimage.osax AppleScript Extension than shelling out to Perl. It adds regular expressions and other goodies organically into AppleScript, and with it installed we end up with this much nicer bit of code:

  set _url to find text "https?://[^[:blank:]\"'”]+" in _url with regexp and string result
on error
  set _url to false
end try

if _url ≠ false then
end if

In any case the script now works for me on that page.

Over time you will probably find more where there is a problem that needs to be worked around.


Although this is a very old topic (May 2015), here is a much simpler, more reliable solution using Execute a JavaScript in Front Browser action provided in KM8, and the Append Variable option in KM9:

MACRO:   Get Hyperlink Under Mouse [Example]

~~~ VER: 1.0    2019-09-16 ~~~
Requires: KM 9.0.2+   macOS 10.11 (El Capitan)+
(Macro was written & tested using KM 9.0+ on macOS 10.14.5 (Mojave))

DOWNLOAD Macro File:

Get Hyperlink Under Mouse [Example].kmmacros
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.




  • The the URL of the Hyperlink Under the Mouse


  1. First, make sure you have followed instructions in the Macro Setup below.
  2. Hover the Mouse Over a valid Hyperlink
  3. Trigger this macro.


  • Carefully review the Release Notes and the Macro Actions
    • Make sure you understand what the Macro will do.
    • You are responsible for running the Macro, not me. ??
      Make These Changes to this Macro
  1. Assign a Trigger to this macro.
  2. Move this macro to a Macro Group that is only Active when you need this Macro.
  3. ENABLE this Macro, and the Macro Group it is in.


  1. KM 9.0+ (may work in KM 8.2+ in some cases)
  2. macOS 10.11.6 (El Capitan)+

TAGS: @URL @Hyperlink @Browser @JavaScript


  • Any Action in magenta color is designed to be changed by end-user


  • To facilitate the reading, customizing, and maintenance of this macro,
    key Actions are colored as follows:
  • GREEN -- Key Comments designed to highlight main sections of macro
  • MAGENTA -- Actions designed to be customized by user
  • YELLOW -- Primary Actions (usually the main purpose of the macro)
  • ORANGE -- Actions that permanently destroy Variables or Clipboards,
    OR IF/THEN and PAUSE Actions


  • While I have given this a modest amount of testing, and to the best of my knowledge will do no harm, I cannot guarantee it.
  • If you have any doubts or questions: