MacOS – Prompting user for input on locking screen

applescriptmacosscripttext input

I'm relatively new to OSX (running Mavericks), but my goal is to create a script that reminds me to take notes on the day's work. The script will ideally: run upon the user clicking 'Login window' (i.e. lock screen) and prompt the user for whether or not they want to record notes (ok/cancel). If the user answers OK, then the script will ask for a multiline input, then append the date and time, plus that input, to a text file before locking the screen. If the user clicks cancel or 15 seconds pass without interaction, the dialog should be dismissed and the screen will lock.

I'm:

1) unsure about how to prompt the user for multiline input

2) unclear how to trigger the script on the user requesting a return to the login window (lock screen?)

If this can be accomplished through a third-party program/interface, I'm open to that as well. Thanks!

Best Answer

Keyboard Maestro.

What you want to achieve requires a daemon that runs in the background, launches with the system, and executes customized commands/scripts after detecting a trigger. It's no a small feat if you want to write one that has good stability.

Apart from the keys, Keyboard Maestro has triggers like Startup, System Wake, Login, While Logged In, etc. With some tweaking and compromise, this is the best shot I know.