borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Form Title Bar Color)Next Topic (How to List All Objects) New Topic New Poll Post Reply
AndreaVB Forum : API : VB app. idle time
Poster Message
Sekar
Level: Sage

Registered: 11-03-2004
Posts: 63

icon VB app. idle time

My app. has around 100 forms. I want to display a message or close the app. when the user dosen't use the app. for 15 minutes after they logged on. I mean I want to find out the app. idle time. Thanks in advance.

02-09-2004 at 03:23 AM
View Profile Send Email to User Show All Posts | Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon Re: VB app. idle time

I dont know of any easy way to do so. My idea would be to hook to keyboard/mouse events and remember the last time keyboard/mouse was used in your application. If you are not familiar with hooking, it would not be an easy task. There are some examples of leyboard hooking in this forum. If you are stuck somewhere, post here and we will help you.

____________________________
If you find the answer helpful, please mark this topic as solved.

02-09-2004 at 10:46 AM
View Profile Send Email to User Show All Posts | Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: VB app. idle time

well... if you haven't done anything yet...

there is also a hook that is activated if the application is idle (not the computer, just the application)... it'd be a bit complex to keep track of it , but the general format is (other hooks are similar):


' Module

Public Const WH_CALLWNDPROC = 4
Public Const WH_CBT = 5
Public Const WH_DEBUG = 9
Public Const WH_FOREGROUNDIDLE = 11
Public Const WH_GETMESSAGE = 3
Public Const WH_HARDWARE = 8
Public Const WH_JOURNALPLAYBACK = 1
Public Const WH_JOURNALRECORD = 0
Public Const WH_KEYBOARD = 2
Public Const WH_MAX = 11
Public Const WH_MIN = (-1)
Public Const WH_MOUSE = 7
Public Const WH_MSGFILTER = (-1)
Public Const WH_SHELL = 10
Public Const WH_SYSMSGFILTER = 6

Private Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal ncode As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
Public Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long

public hIdleHook as long


Public Function IdleProc(ByVal idHook As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Debug.Print idHook
    If idHook >= 0 Then
    ' Application's at idle state (not doing anything)
        Debug.Print wParam & "  -  " & lParam
        Debug.Print "Idle State"
    End If

' Call next hook
    IdleProc = CallNextHookEx(hIdleHook, idHook, wParam, lParam)
End Function




'Form
Private Sub Form_Load()
    hIdleHook = SetWindowsHookEx(WH_FOREGROUNDIDLE, AddressOf IdleProc, App.hInstance, App.ThreadID)
End Sub

Private Sub Form_Unload()
    UnhookWindowsHookEx hIdleHook
End Sub



____________________________
Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)

04-09-2004 at 05:06 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
AndreaVB Forum : API : VB app. idle time
Previous Topic (Form Title Bar Color)Next Topic (How to List All Objects) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder