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:
- Right-click on the image
- 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.
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
- Read the Quick Start.
- This is essential to become familiar with KM terminology
- Do the tutorial (Help ➤ Tutorial) in the KM Editor.
- Gives you a live walkthrough of creating a macro in the KM Editor
- Review/Browse the Available Macro Actions
- For Help with an Action in your Macro, click on the gear icon at the top right of the Action, and select "Help"
- Search the Keyboard Maestro Wiki for detailed help.
- Start small, and grow your macros organically.
- Be prepared for some trial and error in the beginning.
- Make good use of this Keyboard Maestro Forum
For more help, see Getting Started with Keyboard Maestro and the Forum .
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
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.
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?
Safari should work fine.
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.
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.
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...
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:
- Uncheck and delete KBM & KBM Engline
- Reboot machine
- 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.
Glad you get your macro going.
I was able to get it working in Google Chrome a much shorter pause:
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.
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)
The QuerySelector for the avvo page HeadShot is: