I need to search Google Images with a certain image a lot as part of my workflow, and I use KM to automate this for me, but lately the Click on Found Image has become quite unreliable. My script brings up Google Images, clicks the Paste Image URL (but 80 pixels over, so it clicks Upload an Image, then clicks the upload box, then uses the keyboard to select the image I've prepared in a specific location. Are there better wats to do this, like telling the Javascript object to accept a click, or pushing the image directly to google without using this form?
Part of the problem might be that a Chrome window might be zoomed to 100, 110% or 125% normally, and that's got to be hard for KM to "see" all the time. I currently try to click three times at each of those sizes, and it used to work, but it stopped working. I turned off "screen recording" permissions then turned them back on, but still not reliably working.
I do this with Alfred and this workflow. All you have to do is select an image file and either hit a hotkey or invoke Alfred and type your keyword. The free version of Alfred will do this for you, and is worth having anyway.
There's also this thread, but I'm a noob when it comes to python, so I've asked @ccstone to explain a bit more how to get it working.
I never got into Alfred seriously even though it's got a steller reputation. KM is just so perfect. Is the Alfred method doing anything like clicking on a found image, or using another more reliable method like identifying the clickable object by its name inside the source code?
Neither. You just select a file, run the workflow and it opens a Google reverse image search in your default browser. Same as the other thread I posted, although I haven't figured out how to install the python script yet.
I have created a macro that allows Google Image Search by Screen Region Capture or from selected image files from Finder.
You may want to try it and see if that works for you. It does not require other application (eg Python, Alfred) so to make usage easier for users.
For no reason other than fun, I rebuilt your macro. To be clear, this is in no way improved; I just wanted to rebuild it as an exercise. I had no idea you could perform an image search in a shell script. So tidy!
Thanks, I've purchased Alred's power pack since it looks like it has some powerful tools I can use. I imported your script, assigned a keyboard shortcut in the Hotkey box, but get this "the application can't be opened" error. Any idea what I'm doing wrong?
@macdevign_mac cleverly thought to upload to Google Image Search via a shell script. The macro will either upload the currently selected file or take a screenshot and then upload that.
I have it installed and manually assigned a keyboard shortcut. When I run it I get the error from Alfred. Below is some debugging code if that helps. Maybe there's an additional piece I don't have installed?
[22:49:04.774] Google Similar Images[Hotkey] Processing complete
[22:49:04.778] Google Similar Images[Hotkey] Passing output '' to Run Script
[22:49:04.984] Google Similar Images[External] Processing complete
[22:49:04.987] Google Similar Images[External] Passing output '/Users/pp/Documents/BTSync/Peter Sync/ARCHIVE/POST/doukichan and senpaisan ganbare doukichan and 1 more drawn by yomu_sgt_epper DanbooruCLVX_1.jpg' to Run Script
[22:49:04.989] Google Similar Images[External] Passing output '/Users/pp/Documents/BTSync/Peter Sync/ARCHIVE/POST/doukichan and senpaisan ganbare doukichan and 1 more drawn by yomu_sgt_epper DanbooruCLVX_1.jpg' to Post Notification
[22:49:04.995] ERROR: Google Similar Images[Run Script] /Users/pp/Library/Caches/com.runningwithcrayons.Alfred/Workflow Scripts/99F96803-F81B-4F14-A367-F163129D9D0A: line 3: /usr/bin/python: No such file or directory
[22:49:04.997] Google Similar Images[Run Script] Processing complete
[22:49:04.998] Google Similar Images[Run Script] Passing output '' to Open URL
[22:49:05.050] STDERR: Google Similar Images[Run Script] 1 image(s) selected
[22:49:05.054] Google Similar Images[Run Script] Processing complete
[22:49:05.055] Google Similar Images[Run Script] Passing output '' to Post Notification
So I've installed python with Brew and now I have python3 in /opt/homebrew/python3. I am randomly guessing I need to edit the script to point to that? I changed it to
/opt/homebrew/python3 url_for_image.py "{query}"
and now the error I get is
[14:23:47.041] Google Similar Images[Hotkey] Processing complete
[14:23:47.048] Google Similar Images[Hotkey] Passing output '' to Run Script
[14:23:47.175] ERROR: Google Similar Images[Run Script] ./call_with_finder_selection.applescript:1120:1121: script error: Expected end of line, etc. but found “"”. (-2741)
[14:23:47.177] Google Similar Images[Run Script] Processing complete
[14:23:47.180] Google Similar Images[Run Script] Passing output '' to Post Notification
The reason I ask is that the workflow I attached to my first post was exported from my Alfred library. I think perhaps you need to download the workflow from the site and run it to install the python script. As I said, I didn't have to think about python; I just installed it and it worked, which is what has led me to this line of thinking.
OK I've deleted my old workflow and re-downloaded it again from the above link. The keyboard shortcut is removed and the Python command in the upper middle box is restored to /usr/bin/python
So I've now added just the keyboard shortcut and run it. After turning on Accessibility permissions(which it didn't ask for before) I get this debugging feedback
[15:03:41.874] Google Similar Images[Hotkey] Processing complete
[15:03:41.878] Google Similar Images[Hotkey] Passing output '' to Run Script
[15:03:42.017] ERROR: Google Similar Images[Run Script] ./call_with_finder_selection.applescript:1120:1121: script error: Expected end of line, etc. but found “"”. (-2741)
[15:03:42.018] Google Similar Images[Run Script] Processing complete
[15:03:42.022] Google Similar Images[Run Script] Passing output '' to Post Notification
Do I have the right python installed? I just did it through Brew.