How Do I Automate Fill of GMail Compose Form?

Hey @KM_Panther,

I think you need to make a movie demonstrating your exact process.

JavaScripting a web browser to extract and insert text from UI elements is so fiddly that it doesn’t take much miscommunication to waste everyone’s time.

-Chris

Chris,

I'm sorry for any confusion, but my only problem is getting the body of the Gmail message into a KM variable using your offered script! I'm not attempting to automate fill of a form as the original poster, so I don't think a video is necessary. Here's the macro:

Keyboard Maestro 8.2 “Gmail Message Body Macro”

I have shared my Script Editor results from two prior attempts to adapt your script with my two prior posts. Do the results I've shown suggest something more than a syntax issue with my two scripts?

I'm not having any trouble getting a JavaScript solution to read the gmail body.
Here's what the HTML looks like in Chrome Inspect tool:

image

And these JavaScript statement in the Chrome Console all worked fine:

EDIT: 2018-04-25 19:54 GMT-0500

  • Sorry, first example does not always work
  • But this does seem to work on multiple emails:
gmBodyElem2 = document.querySelector('div.a3s.aXjCH');
gmBodyElem2.innerText;

Just put this script in a KM JavaScript in Front Browser, and test:
In Chrome, open an email, then trigger this macro.

image


Your results?

Revised my above post.

JMichaelTX,

Works perfectly!!!

“Not to look a gift horse…” But could I be placing my cursor incorrectly for the Inspect[ion]? I showed my results from the Inspect a few posts back and there was no recognizable id. Did you see that? I must be doing something incorrectly.

Thank you very much.

1 Like

You were close. Go about 5 lines up from the blue highlighted line, and you will see it.

I know I tried using id “3gz” in at least one of the many previous attempts, but I must have done it incorrectly! :confused:

Thanks again for the guidance and support. :relieved:

I found using the "id" attribute to not be reliable, as it can change from one email to another. That's why I switched to using the "class" attribute.