ralph44e
asked on
Monitoring Inactivity in Delphi
I'm writing a program and I need a way to enable a timer when
a user stops all activity on a computer(mouse movement, keyboard)
The program will always be running in the System tray.
Any code would be appreciated.
a user stops all activity on a computer(mouse movement, keyboard)
The program will always be running in the System tray.
Any code would be appreciated.
try this simple code.
function secondsIdle: dword;
var liInfo: TLastInputInfo;
begin
liInfo.cbSize := SizeOf(TLastInputInfo) ;
GetLastInputInfo(liInfo) ;
Result := (GetTickCount - liInfo.dwTime) DIV 1000 ;
end;
Now have a timer set on every 30 seconds:
if secondsIdle > 10000 then begin
form1.caption:='User has been idle for more than 10 minutes!';
end;
function secondsIdle: dword;
var liInfo: TLastInputInfo;
begin
liInfo.cbSize := SizeOf(TLastInputInfo) ;
GetLastInputInfo(liInfo) ;
Result := (GetTickCount - liInfo.dwTime) DIV 1000 ;
end;
Now have a timer set on every 30 seconds:
if secondsIdle > 10000 then begin
form1.caption:='User has been idle for more than 10 minutes!';
end;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
use a TApplication ("Additional" tab in the components list)
and use the "OnIdle" event
and use the "OnIdle" event
I thought this question was about any idle period in any application
Create a screen saver
http://www.mindspring.com/~cityzoo/scrnsavr.html
http://delphi.about.com/od/screensavers/
http://www.pcmag.com/article2/0,1759,1180484,00.asp
http://www.delphifaq.com/fq/q2192.shtml
http://community.borland.com/article/0,1410,26652,00.html
Set the screen saver to the Desktop default, using the inactivity time limit you want.
========================
I probably need a bit more information on what you are trying to do.
1. Do you want to start a timer or reset a timer when mouse/keyboard events happen?
2. Do you want to take some action if the interval between events exceeds some preset limit?
3. What do you want to do when the system goes into power-save mode?
4. What do you want to do when the user logs off?
5. How is your application started?
6. Is your application running as a Windows service?