If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Detect if the user is REALLY using the app. or if it's just loaded.

Hello,

I need to find a way to detect if the application is being used or is just
loaded. It should me almost like a screen saver, but only for the
application. What I mean is the following: if the operator has left the
application loaded with his (hers) logon information and is not using the
application for, let's say, 5 minutes ... when he try to use the application
he'll be asked for logon information again.

Re: Detect if the user is REALLY using the app. or if it's just loaded.

A simplest way would be to make use of a Timer and writing the interval elapsed
to a simple text file periodically(say) every 1 minute. Now, if an event
happens in the application, immediately read the info from the text file
and find out the interval. If it is (say) greater than 5 minutes, then ask
him to log on again. I can't think of any other solution.

Now the question is whether you are using a std .EXE or an activex .DLL.
The way you use the timer control will differ. For example, you can add the
timer to the form in a std .EXE but you have to add the object reference
to the .ocx file if you are using an activeX .DLL.

Hope it helps,
Rgds,
Siva

"Jeverson" <jemd@bol.com.br> wrote:
>Hello,
>
>I need to find a way to detect if the application is being used or is just
>loaded. It should me almost like a screen saver, but only for the
>application. What I mean is the following: if the operator has left the
>application loaded with his (hers) logon information and is not using the
>application for, let's say, 5 minutes ... when he try to use the application
>he'll be asked for logon information again.
>
>I hope I've made myself clear ...
>
>Thanks in advanced
>
>All my Best
>
>#Jé-Pá#
>
>

When you want to track idle time call the above Hook and start a timer on the form to fire say every 10 seconds. In each timer event increment glIdleTime by 10. When ever you want to check how long the user has been idle check the value of glIdleTime. Be sure to call Unhook when you are closing down.

How does this work? The windows hook mechanism allows you to preview messages going to any window. In the case of VB you are limited to windows with in your own app but that's what we want. In this case we are not interested in the messages themselves just that there were some. Hence by hooking the keyboard and the mouse we can determine if the user is active in the app.

I have just presented the basics here. In my ildle timer module I also use SetTimer/KillTimer APIs along with a TimerProc call back function to eliminate dependence on a timer control.