Adobe AIR has a simple API for detecting if a user is idle based on keyboard and mouse activity. Developers can add code to their application to auto-save data locally (using AIR's local database or file access), lock the application until a password is entered, etc.
This sample and many others are available in Tour de Flex.
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundColor="#323232"
verticalAlign="middle" horizontalAlign="center" creationComplete="init()" viewSourceURL="srcview/index.html">
<mx:Script>
<![CDATA[
import flash.desktop.NativeApplication;
import mx.controls.Alert;
private const IDLETIME:int = 5; //Seconds
private function init():void {
NativeApplication.nativeApplication.idleThreshold = IDLETIME;
NativeApplication.nativeApplication.addEventListener(Event.USER_IDLE, onIdle);
NativeApplication.nativeApplication.addEventListener (Event.USER_PRESENT, onPresence);
idlemsg.text = "Status: Active - status will change if idle for more than " + IDLETIME + " seconds";
}
private function onIdle(event:Event):void {
idlemsg.text = "Status: Idle for at least " + IDLETIME + " seconds";
}
private function onPresence(event:Event):void {
idlemsg.text = "Status: Active again - status will change if idle for more than " + IDLETIME + " seconds";
}
]]>
</mx:Script>
<mx:Label id="idlemsg" color="white"/>
</mx:WindowedApplication>