[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Idle Time



How to find out the idle time, normally used by screen savers etc., from
MacPerl?

Install the IdleTime extension. It's at info-mac and it comes with the
Frontier distribution.
Be sure that the Finder is running and run the following snippet.
Move the mouse or hit a key at times while it is running.

use Mac::AppleEvents;

sub getIdleTime {
 my $be =
AEBuildAppleEvent('fndr','gstl',typeApplSignature,'MACS',0,0,"'----':ÒidleÓ") ||
die "$!\n";
 my $reply = AESend($be, kAEWaitReply) or die $^E;
 AEDisposeDesc $be;
 (AEPrint($reply) =~ /aevt\\ansr{'----':(\d+)}/) ? return $1 : die $^E;
}

foreach (1..100){
 print "Nothing happened for ", getIdleTime, " ticks.\n";
}

In AS the sub is equivalent to:

tell application "Finder"
	return computer "idle"
end tell

Now the question is if and how it is possible to directly access this
Gestalt selector via Gestalt.pm. Any sample code is greatly appreciated.


__Peter Hartmann________

Ritsumeikan University, Kyoto, Japan

e-mail:
hartmann@mbox.kyoto-inet.or.jp (preferred)
phv00542@askic.kic.ritsumei.ac.jp




***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch