Access to selection in gmail message body with Google Apps Script
Posted
by
Mike Ellis
on Stack Overflow
See other posts from Stack Overflow
or by Mike Ellis
Published on 2012-10-18T14:06:07Z
Indexed on
2012/11/21
17:00 UTC
Read the original article
Hit count: 329
Can app scripts access the current selection in a gmail message?
I frequently compose messages that include engineering calculations and make use of the Google Calc feature do the calculation or convert to the desired units, e.g.
4000 Btu/hr * 8 hrs in kWh
It would be really convenient to be able to select the above, hit a mapped key (e.g. Ctrl-K) and have the inserted after the expression
4000 Btu/hr * 8 hrs in kWh = 0.9378 kWh
instead of having to paste the expression into a search box and then copy and paste the answer.
I could certainly write a solution using a keymapper and a small python script to grab the current selection, send it to the gcalc api, etc ..., but my real motivation is to get familiar with Apps Scripts's capabilities and limitations.
I suppose the uber-question here is "what kinds of user actions and state information can App Script access in Gmail messages (and/or Google docs) that are being edited?"
© Stack Overflow or respective owner