auto timeout for winform application

D

Dayne

I need to have a auto timeout feature for a webform application(vb.net).
Basically, I want to close the application if the user does not have a
keyboard or mouse input after a specific period of time. Please help!

Dayne
 
N

Nick Malik

Hello Dayne,

Do you want to close the app if the user doesn't touch the App, or if the
user doesn't touch Windows?
There's a difference.

Let's say I use your app, then minimize it, and open up Excel. I type in
Excel for an hour. Should you app time out?
If not, then you need to hook the windows event. The article that Wayne
sent is appropriate.
If, on the other hand, you want to close because no one has touched your app
in an hour, then you can simply set a timer in your app and when you get
keystrokes or clicks, set the current datetime in a static location. When
your time goes off, check to see if "too long" has occured, and if so,
close.

One problem: it isn't clear if your app is ASP.NET or is a Windows forms
app. In your title, you way Winform, but in the text you say webform.

If it is a web form, you have a totally different problem.
--- Nick
 
O

One Handed Man \( OHM - Terry Burns \)

Use a javascript timer on the web client which should be reset each time a
user enters text or moves focus from one control to another, if the timer
event ever fires you can window.close()

HTH

--
OHM ( Terry Burns ) * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
 
O

One Handed Man \( OHM - Terry Burns \)

The title of the OP's post says Winform, but in the text he says WebForm



--
OHM ( Terry Burns ) * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
 
C

Cor Ligthert

Dayne,

Assuming it is a windowform, than I think that you can use something as this
beneath when it is a webform you can do as Terry told, in is almost the same
way as this. And please stay as Herfried told as well next time in the
original question thread.

\\\Need a webform and some controls however a button and a textbox as
minimum
Private WithEvents mytimer As New Windows.Forms.Timer
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
doSet(Me)
End Sub
Private Sub doSet(ByVal parentCtr As Control)
Dim ctr As Control
For Each ctr In parentCtr.Controls
AddHandler ctr.Click, AddressOf eventfired1
AddHandler ctr.Enter, AddressOf eventfired1
AddHandler ctr.KeyDown, AddressOf eventfired2
doSet(ctr)
Next
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles mytimer.Tick
Me.Close()
End Sub
Private Sub eventfired1(ByVal sender As System.Object, _
ByVal e As System.EventArgs)
eventfired()
End Sub
Private Sub eventfired2(ByVal sender As System.Object, _
ByVal e As Windows.forms.KeyEventArgs)
eventfired()
End Sub
Private Sub eventfired()
mytimer.Enabled = True
mytimer.Stop()
mytimer.Interval = 3000
mytimer.Start()
End Sub
///

I hope this helps a little bit?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top