How to capture the system idle time in c/c++

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2006
Posts: 3
Reputation: mohit_mar is an unknown quantity at this point 
Solved Threads: 0
mohit_mar mohit_mar is offline Offline
Newbie Poster

How to capture the system idle time in c/c++

 
0
  #1
May 9th, 2006
I want to capture the system idle time. Means if the user did not press any key or did not move the mouse then it is considered as system idle time. I want the code for this in C or C++ on windows operating system. Please help me. It's urgent....



Thanks & Regards
Mohit Malhotra
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,622
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1493
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: How to capture the system idle time in c/c++

 
0
  #2
May 9th, 2006
There are probably a number of ways to solve that. The solution I took was to create another listener thread. The main program thread sends a message to this listerner thread every keyboard and mouse event. The listner thread waiks up from Sleep() every minute and checks its input queue. If nothing then it knows there has been no keyboard or mouse activity during the last minute and can take appropriate actions.

You might also use SetTimer() and and capture WM_TIMER events. The os will call a function of your choice after the specified amount of time has elapsed. The main program could have a counter that increments each time a keyboard or mouse event occurs, then the timer function just checks that counter -- if counter is zero then there were no events.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: How to capture the system idle time in c/c++

 
0
  #3
May 9th, 2006
> Please help me. It's urgent....
http://www.catb.org/~esr/faqs/smart-...ns.html#urgent

http://www.daniweb.com/techtalkforums/thread29300.html
Dredging up long dead threads with pointless "me too" queries won't buy you much sympathy either.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC