MACSCRPT Archives

November 2007

MACSCRPT@LISTSERV.DARTMOUTH.EDU

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

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

Print Reply
Mime-Version:
1.0 (Apple Message framework v915)
Content-Type:
text/plain; charset=US-ASCII; format=flowed; delsp=yes
Date:
Fri, 30 Nov 2007 21:04:43 +0000
Reply-To:
Macintosh Scripting Systems <[log in to unmask]>
Subject:
From:
Simon Topliss <[log in to unmask]>
In-Reply-To:
Content-Transfer-Encoding:
7bit
Sender:
Macintosh Scripting Systems <[log in to unmask]>
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