I'm currently working with Google Apps Script in Google Docs. I want to track every movement of the cursor, storing the position using the Position.
How can I do?
I created an onOpen
function that recalls another function that has an infinite loop inside, trying to store the current position with:
DocumentApp.getActiveDocument().getCursor()
TL;DR: Don't do that for serious projects.
In Google Apps Script,
"Infinite loops" aren't infinite, as there is a time execution limit. Because of this, once the execution reaches the time limit, it will throw an error. Just to let you know, time-driven triggers have a daily total execution time quota. The alternative to this might be to use a sidebar to run the infinite loop using client-side code and google.script.run
to call a function that gets the cursor position.
Google Apps Script services are slow, and there are undisclosed quotas to prevent disruptions in the server operations due to abuse (including edge cases). Because of this, there is a chance that only some of the cursor positions will be correctly logged.
Related