MACSCRPT Archives

November 2007

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Simon Topliss <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Fri, 30 Nov 2007 21:04:43 +0000
Content-Type:
text/plain
Parts/Attachments:
text/plain (35 lines)
On 30 Nov 2007, at 19:12, Stockly, Ed wrote:

> Is there a shell command that will return how much time has passed  
> since the
> last time a user moved or clicked the mouse or hit a key on the  
> keyboard?
>
> ES


I use this for modifying Skype's status in an idle handler.

on checkSkypeIdle()
	log "checkSkypeIdle()"
	set r to rnd(do shell script "ioreg -c IOHIDSystem | perl -ane 'if(/ 
Idle/) {$idle=(pop @F)/1000000000; print $idle, \"\\n\"; last;}'")
	if r < 600.0 then
		checkSkypeStatusIsOnline()
	else
		checkSkypeStatusIsOffline()
	end if
end checkSkypeIdle
	
	
(* Round to nearest (.5 away from zero) *)
on rnd(n)
	n div 0.5 - n div 1
end rnd


Sorry to anyone who's code that I've used without referencing the  
original author (Nigel?).

Simon

ATOM RSS1 RSS2