Access to selection in gmail message body with Google Apps Script
- by Mike Ellis
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?"