[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Detecting Idle Time in Delphi

Posted on 2012-03-29
8
Medium Priority
?
1,092 Views
Last Modified: 2012-03-29
I have an app that needs to detect when the whole system has not received any input from keyboard or mouse for a few minutes. I've found some very complicated hooking examples online which involve DLLs and some others that simply don't work. Can anyone suggest a straight forward way of doing this.
0
Comment
Question by:ChrisJonesLycos
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 23

Expert Comment

by:Ferruccio Accalai
ID: 37782571
what about using GetLastInputInfo?
edit: you need it systemwide, so this function can't help you :(

function SecondsIdle: DWord;
var
  liInfo: TLastInputInfo;
begin
  liInfo.cbSize := SizeOf(TLastInputInfo);
  GetLastInputInfo(liInfo);
  Result := (GetTickCount - liInfo.dwTime) DIV 1000;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Caption := Format('System IDLE last %d seconds', [SecondsIdle]);
end;

Open in new window

0
 

Author Comment

by:ChrisJonesLycos
ID: 37782607
The MSDN documentation says that that's for your own window only, not system wide.
0
 
LVL 23

Expert Comment

by:Ferruccio Accalai
ID: 37782626
No wait, it says literaly "GetLastInputInfo does not provide system-wide user input information across all running sessions. Rather, GetLastInputInfo provides session-specific user input information for only the session that invoked the function"
It speaks about sessions, not "window"
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:ChrisJonesLycos
ID: 37782640
Is that not the same? I'll try out some code and see what result I get.
0
 
LVL 23

Expert Comment

by:Ferruccio Accalai
ID: 37782662
For a session I mean a User session. If you have some user remotely connected that's a separate session I guess. It's like it works into HKCU instead of HKLM
Anyway, everywhere I read, the suggested approach for a system idle detection is this.
0
 

Author Comment

by:ChrisJonesLycos
ID: 37782700
I've requested that this question be closed as follows:

Accepted answer: 0 points for ChrisJonesLycos's comment #37782640

for the following reason:

Cool. You're right, code works! Session obviously doesn't mean just your own app, it's definitely system wide. Many thanks.
0
 
LVL 23

Accepted Solution

by:
Ferruccio Accalai earned 2000 total points
ID: 37782701
@Cool. You're right, code works! Session obviously doesn't mean just your own app, it's definitely system wide. Many thanks.

So why a Close Request? Don't you think you should accept my comment as answer?
0
 

Author Closing Comment

by:ChrisJonesLycos
ID: 37782732
I accepted your solution. Not sure what happened.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question