Copying an Image from a Profile Web Page

I would like to copy an image that appears at the same location on a webpage and was wondering the best way to do it. My current thinking is:

  1. Right-click on the image
  2. Select Copy Image to the Clipboard

If this is the best way, how do I select the menu option "Copy Image" from the pop-up menu that appears when right-clicking on the image?

I have also thought about copying the area of the page but that would probably result in a much lower quality image than copying the image.

Thanks
Steve

Here is a quick and unreliable macro that will do the job. I say unreliable because it requires the image to always be in the same place, visible from the top of the page, and your browser window to always have the same dimensions. It's a starting point though.

You will need to edit the hotkey, and the location of the image. You can use the "Get" button on the mouse move/click action to set the location inside your browser window where you want to click. If you need to scroll first then you should add a simulate scroll function.

copy web image to clipboard.kmmacros (2.9 KB)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@photoRobertson , welcome to Keyboard Maestro (KM) and its Forum.
KM is one of the best Mac automation tools available, the its Forum is one of the best and friendliest forums on the Internet. Whenever you reach a tough stumbling block trying to use KM, please feel free to post your question/problem here for help.

You will also find this helpful:
Tip: How Do I Get The Best Answer in the Shortest Time?

Getting Started with Keyboard Maestro

For more help, see Getting Started with Keyboard Maestro and the Forum .

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

1 Like

Thanks but it is not working yet. Should I be able to see the actual pop-up menu in the right-click action because it is not occurring.

Do you need it at a higher quality than as displayed on the screen? Because Keyboard Maestro could simply capture the screen area for you, which would be trivial.

Yes, I can't just copy the screen because a low res image is masked inside of a circle. I need to copy the actual square full file. Thanks

Hey Steven,

What web browser are you using?

What web page?

The best solution may be to parse the page for the image and then download it.

-Chris

That's an interesting solution. I am using Safari, but could use Chrome on the Mac.

In regards to the original solution, should I be able to physically see Keyboard Maestro perform a right-click and select the menu option, or will this occur in the background with no visible event?

I am writing this for two different web pages including a LinkedIn Profile page. I have also used an action to set the exact window size prior to performing the right-click so it should work but doesn't for some reason. Do I need to enable something somewhere? I already have accessibility turned on for Keyboard Maestro.

Hmm, yes, I think you should see the right click context menu. Perhaps a short pause between right clicking and typing would help?

In any case, if it is in the same part of the page each time then using javascript to get the image URL and downloading it might work better. I'm currently working on a macro to do just that for something else but I suspect other users would give you a better solution as I'm far from an expert.

Hey Steven,

Safari should work fine.

Yes.

No.

Please provide the URL to an actual page, so we can test with the same data.

Pick someone neutral on LinkedIn if necessary.

That should be sufficient.

You can manually right-click the image? Sometimes web pages disable right-click.

-Chris

Try the "Move or Click mouse" action:
there you can specify ==right click== at X,Y coordinates
then another action can move the mouse down the menu and click at copy image

No. I can right-click on the image and see the menu.

Here are two sample web pages that I am looking at copying the image.

  1. https://www.avvo.com/attorneys/37402-tn-morgan-adams-639727.html

  2. https://www.linkedin.com/in/bamidele-bami-adelayo-3b426824/

I tried my script in Google Chrome with the same effect. Other Macros such as Activate Google Chrome and resizing windows works fine. It is just the Right-click macro that is not working with either browser for some reason.

And I am using version 8.2.4 of Keyboard Maestro on an iMac running Mojave

for the avvo one try separating the action in two, one for moving, one for right-clicking:
1.- Move or click mouse: just move to absolute position 205, 321
2.- Move or click mouse: Right click
works in Safari.
also you might need to add a pause if your computer is too fast.

The problem is that even if my mouse click is at the wrong location, I should still see the right-click menu and I am not seeing it. Its like the Right Click action is not performing at all. Here is my steps I am trying...

14%20AM

dumb question:
in your computer > System Preferences > Security & Privacy
did you allow KM and the KM engine in the Accessibility and th eAutomation tabs?
they should have a check next to their icon, or if you don't see them, you should add them.

OK, I got the right-click macro to start working by performing the following:

  1. Uncheck and delete KBM & KBM Engline
  2. Reboot machine
  3. Reneable KBM & KBM Engine settings when prompted by Keybard Maestro

But, now I have a new problem. the right menu appears, but the "Insert Text by Typing" macro is not working so the menu item is not selected. And it also scrolls the web page up.

Finally solved that issue too but putting a 2 second pause before typing the text.

SOLVED!

Hey Steven,

Glad you get your macro going.  :smile:

I was able to get it working in Google Chrome a much shorter pause:

image
Even on my old Mid-2010 MacBook Pro I was able to get Safari to work reliably with only a 0.5 second pause, although I haven't added many extensions.

This brute-force method of getting the profile pic is likely quite adequate for your needs at the moment, but it's also possible to scrape the image URL from the DOM (Document Object Model) using JavaScript.

Once you have that you can use the curl command line tool (or other) to download the image and then process it however you want.

In this macro I've downloaded the image from the LinkedIn page you referenced above to the /tmp/ directory and then copied it to the clipboard.


This macro may or may not function in KM 8.2.4.

LinkedIn -- Grab Profile Headshot v1.00.kmmacros (6.1 KB)

-Chris

1 Like

Hey Folks,

The QuerySelector for the avvo page HeadShot is:

document.querySelector('img.v-js-headshot').src

-Chris

Hi Chris.

Thanks so much for your advice and suggestions for improvement. Part of the reason I put in longer delays is that for LinkedIn, they don't like it if you use automation tools and will restrict your account for awhile if they detect this. In regards to using Javascript with the DOM is a much cleaner solution and one that I will probably implement in the future as an enhancement as relying on the GetImage macro to determine if a generic photo is there before copying the image to the clipboard is a little kludgy. But for now it works and I just have it run while I am away.

Thanks again
Steve