Inserting thumbnails into Google Sheets

Hi all,

As part of my job I often have to input a large amount of thumbnails into a Google sheet. I created a macro -


This does the job to a certain extent, but will often fail for no discernible reason. I expect this reason to be the varying times it takes for sheets to upload in image - it it takes too long one time it throws the whole thing off.

So I'm trying a different method of uploading all my images to my Google drive and importing from there in the hope the upload ties won't throw things off, but I need cycle through the available images by one more press of the right arrow key each time the macro repeats. Here is the macro as it stands


I just need that penultimate hot key press of the right arrow key to repeat once on the first go round, the twice on the second etc

There was another topic that touched on this kind of thing but I embarrassingly couldn't work out how to download the example macro... here

Thank you!

Your macro looks to be a one-time use thing, that is, there's no loop in there at all. And while it's pretty simple to to make that penultimate keystroke repeat n, n+1, n+2 etc times, the question is when would the variable that's tracking that position get reset?

That is, the way the macro is written, you call it repeatedly to upload the thumbnails, not call once and then let it repeat until the work is done. So let's say you're using it, and you run it 15 times in a row. The value of the repeat tracking variable is now 16, so that the next run happens at the right spot.

But now your boss has you switch tasks for a bit, and you do other things on your Mac. When you come back to your "upload thumbnails" task, is it still valid that the repeat value is 16? Or should it now be zero, because you'll be starting over at a new first row?


Thanks for the reply! Yeah I hadn't set it to repeat yet but I don't mind basically setting it to repeat the number of times for the number of thumbnails (as it's not always the same) as in my original Macro I think is currently set to repeat 84 times. I would like it to reset back to zero each time, I don't have the issue of my boss interrupting me or anything and if I do need to stop it for any reason, I'd rather just delete the photos I've already imported and always know that I'm starting from 0.

[Bad macro deleted.]

Thanks so much for this. I couldn't get the initial repeat prompt to work (every time I pressed OK the dialogue box would just flash and empty) so I added a manual repeat counter in the macro. Weirdly when I do this, the number of presses on the right arrow key increases by an odd number each time, so on the first repetition it increases by 1, on the second 3, on the third 5 etc. I had a fiddle to try and fix it but think I'm out of my depth here...

My apologies, that macro had a few issues ... sigh. First, there's a typo in the regular expression that got in after testing and before posting. Second, I realize now I need to ask for a bit more detail to make it work right:

There are two sections in your macro, "first" and "subsequent." If you say you want to repeat the macro five times, does "first" only run once, on pass number one, and then just "subsequent" gets repeated five times? Or do both "first" and "subsequent" get run all five times?

Sorry for the bad macro, but it'll be a simple fix if you can explain the logic of those two sections versus the overall repeat count.


If you are doing this manually, how do you know when it is time to take the next action? Now see if you can replicate that in your script, rather than relying on hard-coded pauses (which, as you've found, can be quite "fragile" when working with a web service).

For example, uploads often show a progress bar when they are happening -- could you use a "Pause Until" action to wait until that bar is no longer on your screen?


Absolutely no need to apologise! Thanks so much for your help so far! Yeah the "first" action is only supposed to run once the the "subsequent" ones repeat, the logic made sense in my head but probably serves mostly to highlight my inexperience with macros!

Ah thanks so much I hadn't thought of this, waiting until the upload screen disappears would change everything!

Here's an updated version of my macro. I fixed the typo in the regex, and reworked the loop so "First" only happens once. But as noted by @Nige_S, if you can detect the end of the upload, that might be a better solution.

Download Macro(s): SHEETS INSERT THUMBNAIL v2.rob2.kmmacros (23 KB)

Macro screenshot

Macro notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.
System information
  • macOS 14.4
  • Keyboard Maestro v11.0.2