-
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.
I hope I've made myself clear ...
Thanks in advanced
All my Best
#Jé-Pá#
-
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á#
>
>
-
Re: Detect if the user is REALLY using the app. or if it's just loaded.
Place the following code in a module. I'm afraid you will have to find the API declares yourself (I use type libraries).
Public glIdleTime as Long
'--- API Wrap ---
Public Sub Hook()
mhMouseHook = ApiRaiseIfNull(SetWindowsHookEx(WH_MOUSE, _
AddressOf Mouse_IO, 0&, App.ThreadID))
mhKeyboardHook = ApiRaiseIfNull(SetWindowsHookEx(WH_KEYBOARD, _
AddressOf Keyboard_IO, 0&, App.ThreadID))
End Sub
Public Sub Unhook()
ApiRaiseIfNull UnhookWindowsHookEx(mhMouseHook)
ApiRaiseIfNull UnhookWindowsHookEx(mhKeyboardHook)
End Sub
'--- End of API Wrap ---
'--- Api Callbacks ---
Private Function Mouse_IO(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Mouse_IO = CallNextHookEx(mhMouseHook, nCode, wParam, lParam)
glIdleTime = 0 'we've had activity, so reset ticks
End Function
Private Function Keyboard_IO(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Keyboard_IO = CallNextHookEx(mhKeyboardHook, nCode, wParam, lParam)
glIdleTime = 0
End Function
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.
--
Anthony Jones
Nuesoft Ltd
-
Re: Detect if the user is REALLY using the app. or if it's just loaded.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|