For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > January 2006 > Detect idle time









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Detect idle time
Markus Weber

2006-01-09, 7:16 pm

Hello!

Does anybody know how to determine if MS Windows is currently idle.
Menas no applications are running and do something? Maybe there is
Some sort of a Windiows messaage sent?

Thanks in advance!
J French

2006-01-09, 7:16 pm

On Thu, 22 Dec 2005 11:24:22 GMT, m.weber@megalith-software.de (Markus
Weber (Megalith GmbH)) wrote:

>Hello!
>
>Does anybody know how to determine if MS Windows is currently idle.
>Menas no applications are running and do something? Maybe there is
>Some sort of a Windiows messaage sent?
>
>Thanks in advance!



Look at SetWindowsHookEx

- I've never made it work under VB
Markus Weber

2006-01-09, 7:16 pm


thanks for the hint. Base don this function I found an example on
www.vbaccelerator.com. The only problem is that the example uses the
API only for a single thread and not for the whole system. Any ideas?


On Thu, 22 Dec 2005 14:27:20 +0000 (UTC), erewhon@nowhere.uk (J
French) wrote:

>On Thu, 22 Dec 2005 11:24:22 GMT, m.weber@megalith-software.de (Markus
>Weber (Megalith GmbH)) wrote:
>
>
>
>Look at SetWindowsHookEx
>
>- I've never made it work under VB


J French

2006-01-09, 7:16 pm

On Wed, 28 Dec 2005 11:19:07 GMT, m.weber@megalith-software.de (Markus
Weber (Megalith GmbH)) wrote:

>
>thanks for the hint. Base don this function I found an example on
>www.vbaccelerator.com. The only problem is that the example uses the
>API only for a single thread and not for the whole system. Any ideas?


A real example should be in a non-VB non-AX DLL
- that gets magically mapped into the memory of each process

Generally the multiple instances communicate to one point using
SendMessage

If SetWinwsHookEx is used within an EXE it just grabs the stuff for
that EXE - I guess you found that example

An easier solution is to cheat and just monitor the mouse position and
the keyboard using a Timer
- personally I would do that as I've read posts saying that a global
hook is known to conflict with a number of established Apps

If you really want to use a DLL to establish a global hook then I
could point you to some Delphi code that does it


Juergen Thuemmler

2006-01-09, 7:16 pm

> thanks for the hint. Base don this function I found an example on
> www.vbaccelerator.com. The only problem is that the example uses the
> API only for a single thread and not for the whole system. Any ideas?


Have a look at
http://www.mentalis.org/vbexamples/...p?category=MISC
for DS..... Dlls. There are lots of hooks...

Juergen.


Markus Weber

2006-01-09, 7:16 pm

Thnaks for your help, but Im not familiar with delphi or C and I do
not have the cmpilers so I couldn't compile the sources. But thanks.
Heard of a already compiled component which hooks the idle status?

>On Wed, 28 Dec 2005 11:19:07 GMT, m.weber@megalith-software.de (Markus
>Weber (Megalith GmbH)) wrote:
>
>
>A real example should be in a non-VB non-AX DLL
>- that gets magically mapped into the memory of each process
>
>Generally the multiple instances communicate to one point using
>SendMessage
>
>If SetWinwsHookEx is used within an EXE it just grabs the stuff for
>that EXE - I guess you found that example
>
>An easier solution is to cheat and just monitor the mouse position and
>the keyboard using a Timer
>- personally I would do that as I've read posts saying that a global
>hook is known to conflict with a number of established Apps
>
>If you really want to use a DLL to establish a global hook then I
>could point you to some Delphi code that does it
>
>


Markus Weber

2006-01-09, 7:16 pm

Thanks for your help, but there is no DLL which hooks the idle status.

>
>Have a look at
>http://www.mentalis.org/vbexamples/...p?category=MISC
>for DS..... Dlls. There are lots of hooks...
>
>Juergen.
>
>


J French

2006-01-09, 7:16 pm

On Thu, 29 Dec 2005 11:18:40 GMT, m.weber@megalith-software.de (Markus
Weber (Megalith GmbH)) wrote:

>Thnaks for your help, but Im not familiar with delphi or C and I do
>not have the cmpilers so I couldn't compile the sources. But thanks.
>Heard of a already compiled component which hooks the idle status?


This is the link I have
- but I checked it and it is invalid
- I also tried the Wayback machine - no success
www.zenobits.com/projects.php/1/#TIdleDetector

You might be able to hunt something out
- probably me riling the guy into explaining what was going on

I would seriously go for the 'cheap' alternative that I suggested
earlier, monitoring the key state is a simple way of making sure that
the machine is ... sort of ... idle
Randy Birch

2006-01-09, 7:16 pm

http://vbnet.mvps.org/code/system/getlastinputinfo.htm

--

Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/

Please reply to the newsgroups so all can participate.




"Markus Weber (Megalith GmbH)" <m.weber@megalith-software.de> wrote in
message news:43aa8c8a.10895953@msnews.microsoft.com...
: Hello!
:
: Does anybody know how to determine if MS Windows is currently idle.
: Menas no applications are running and do something? Maybe there is
: Some sort of a Windiows messaage sent?
:
: Thanks in advance!

Ken Halter

2006-01-09, 7:16 pm

"Markus Weber (Megalith GmbH)" <m.weber@megalith-software.de> wrote in
message news:43b3c615.615454828@msnews.microsoft.com...
> Thanks for your help, but there is no DLL which hooks the idle status.
>


Here's another. I missed part of the thread so I'm not sure exactly what the
requirements are. This is a very simple way to check idle using a timer and
a couple of API calls to see if there's any keyboard/mouse activity. The app
itself doesn't need to have focus.

Detect Idle and App Auto Shut down
http://www.vbsight.com/Code.htm

While there, might as well take a look at this (below) since I saw someone
mention something about apps communicating with each other. I went a bit
over-board on this one. Had plans for it that never took shape.

Communicate with another instance of your app
http://www.vbsight.com/Code.htm

--
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
Freeware 4 color Gradient Frame? http://www.vbsight.com/GradFrameCTL.htm


Markus Weber

2006-01-09, 7:17 pm

Thanks, I think I will do it in the way you suggested by monitoring
key strokes.

>On Thu, 29 Dec 2005 11:18:40 GMT, m.weber@megalith-software.de (Markus
>Weber (Megalith GmbH)) wrote:
>
>
>This is the link I have
>- but I checked it and it is invalid
>- I also tried the Wayback machine - no success
> www.zenobits.com/projects.php/1/#TIdleDetector
>
>You might be able to hunt something out
>- probably me riling the guy into explaining what was going on
>
>I would seriously go for the 'cheap' alternative that I suggested
>earlier, monitoring the key state is a simple way of making sure that
>the machine is ... sort of ... idle


Markus Weber

2006-01-09, 7:17 pm

This example looks great, I will try it!

>http://vbnet.mvps.org/code/system/getlastinputinfo.htm
>
>--
>
>Randy Birch
>MS MVP Visual Basic
>http://vbnet.mvps.org/
>
>Please reply to the newsgroups so all can participate.
>
>
>
>
>"Markus Weber (Megalith GmbH)" <m.weber@megalith-software.de> wrote in
>message news:43aa8c8a.10895953@msnews.microsoft.com...
>: Hello!
>:
>: Does anybody know how to determine if MS Windows is currently idle.
>: Menas no applications are running and do something? Maybe there is
>: Some sort of a Windiows messaage sent?
>:
>: Thanks in advance!
>


Markus Weber

2006-01-09, 7:17 pm

Thanks this seem like what I need!

On Thu, 29 Dec 2005 12:58:17 -0800, "Ken Halter"
<Ken_Halter@Use_Sparingly_Hotmail.com> wrote:

>"Markus Weber (Megalith GmbH)" <m.weber@megalith-software.de> wrote in
>message news:43b3c615.615454828@msnews.microsoft.com...
>
>Here's another. I missed part of the thread so I'm not sure exactly what the
>requirements are. This is a very simple way to check idle using a timer and
>a couple of API calls to see if there's any keyboard/mouse activity. The app
>itself doesn't need to have focus.
>
>Detect Idle and App Auto Shut down
>http://www.vbsight.com/Code.htm
>
>While there, might as well take a look at this (below) since I saw someone
>mention something about apps communicating with each other. I went a bit
>over-board on this one. Had plans for it that never took shape.
>
>Communicate with another instance of your app
>http://www.vbsight.com/Code.htm
>
>--
>Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
>DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
>Freeware 4 color Gradient Frame? http://www.vbsight.com/GradFrameCTL.htm
>
>


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com