tclWinidle is a tiny library that provides tclWinidle::idletime command, which returns time (in milliseconds), during which user didn't use mouse or keyboard.
Requires Tcl 8.0 or newer (see ActiveTcl Home Page).
tclwinidle-0.2-src.zip
tclwinidle-0.2.zip