Rajesh batchu

in my application i need to know if the system is idle for more than 5 min

my requirement is if the application which i am developing is now open on desktop and if the user of this application dose not give any input to the system for moure than 5 min it should open a dialog which promt the user to input the reason for the idleness

 [SJW: Merged Thread  -please do not multipost]




Re: Visual Basic General system is idle or no input from user

Rajesh batchu

hi all

i am developing an mdi application which concist of 50 forms

my requirement is when the system is idle(no input to the computer) for more than 5 min i should open a form and take reason for idle

can any one help please






Re: Visual Basic General system is idle or no input from user

Dick Donny

Have you investigated the System.Windows.Forms.Application.Idle event It's not system wide but reports whenever you application is about to enter the idle state.

You should be able to attach a handler to it (AddHandler) in your application and perhaps glean the information you are seeking

Any use

Richard





Re: Visual Basic General system is idle or no input from user

Dick Donny

Have you investigated the System.Windows.Forms.Application.Idle event It's not system wide but reports whenever you application is about to enter the idle state.

You should be able to attach a handler to it (AddHandler) in your application and perhaps glean the information you are seeking

Any use

Richard





Re: Visual Basic General system is idle or no input from user

Rajesh batchu

dear dick donny,

i did not get what u mean to say will u please explain me in detail or please give me the code how to do this

in my mdi application i have prepared a form with border style non and when my application is running and the system is idle or there is no input from the user for more than 5 min i should pop up this form and request the user to enter the details why he was idle for past five min






Re: Visual Basic General system is idle or no input from user


Re: Visual Basic General system is idle or no input from user

Tall Dude

Lots of other issues to deal with

on your program, but to answer the basic question:

Public Class Form1

Public Structure LASTINPUTINFO

Dim cbSize As Integer

Dim dwTime As Integer

End Structure

<Runtime.InteropServices.DllImport("user32.dll")> _

Shared Function GetLastInputInfo(ByRef plii As LASTINPUTINFO) _

As Boolean

End Function

Private Declare Function GetTickCount _

Lib "kernel32" () As Integer

Private Sub Timer1_Tick(ByVal sender As Object, _

ByVal e As System.EventArgs) Handles Timer1.Tick

Dim plii As LASTINPUTINFO

' Setup the size

plii.cbSize = Len(plii)

' Get the time of the last user input

GetLastInputInfo(plii)

' Display the idle time

' (last user input is the last ms of the input, not idle time...

' to get idle time, take the current tick count - the last input

' time)

' EX (for clarification): if last user input was at 2:00pm, and

' it's now 2:01, 60 seconds, or 60*1000 ms have elapsed

' (2:00 - 2:01 = :01 = 60sec, = 60*1000)

TextBox1.Text = CStr(Int((GetTickCount - plii.dwTime) / 1000)) 'for seconds

If TextBox1.Text = "300" Then

Timer1.Enabled = False

Form2.ShowDialog()

End If

End Sub

End Class






Re: Visual Basic General system is idle or no input from user

Rajesh batchu

Thank's Tall Dude

it has helped me but i should make changes to that code according to my requirement