• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 239
  • Last Modified:

how to close VB application if the computer is inactive for a certain time?

i have made a VB .exe file for my users. but i want to close the application if a the user leaves it open and goes away.
it is not that urgent but it is certainly required by me.
0
bigbug7
Asked:
bigbug7
1 Solution
 
GrahamSkanRetiredCommented:
The straightforward answer is to have a timer procedure which ends the program after a defined period of inactivity. To detect the inactivity, reset the timer in the events of enabled forms and controls. You won't need to hook all events, probably MouseDown and KeyDown would be enough.

Something like this:

Public gEndTime As Date

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    gEndTime = DateAdd("h", 1, Now())'Period of one hour
End Sub


Private Sub Timer1_Timer()
   Timer1.Interval = 60000
   If Now() > gEndTime Then
       End
   End If
End Sub


 
0
 
avya2kCommented:
Insert one timer control and do as folowing

Dim tm As Date

Private Sub Form_Activate()
    tm = Now
End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
    tm = Now
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    tm = Now
End Sub

Private Sub Timer1_Timer()
    Debug.Print DateDiff("s", tm, Now)
    If (DateDiff("s", tm, Now) > 5) Then End
End Sub


0
 
avya2kCommented:
set timer.interval=1000
'This will check for interaction with form for every second
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Éric MoreauSenior .Net ConsultantCommented:
I have a sample I can send you if you give your e-mail address.
0
 
CleanupPingCommented:
Hi bigbug7,
This old question (QID 20555746) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
0
 
GPrentice00Commented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

-->PAQ - with points refunded

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

GPrentice00
EE Cleanup Volunteer
0
 
YensidModCommented:
Question is PAQ'd and no points refunded.

YensidMod
Community Support Moderator @Experts Exchange
0
 
bigbug7Author Commented:
my email address is bigbug7@hotmail.com
0
 
Éric MoreauSenior .Net ConsultantCommented:
Now that the question is closed, you are back!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now