Solved

Catching an interval of non-activity on computer...

Posted on 2000-02-21
5
145 Views
Last Modified: 2010-05-02
I would like to know how to catch a time period of say 2 minutes or 20 seconds or half an hour of inactivity in an event or a method so i can start a screensaver myself, or I can automatically log-out the user that is looged in.

Please help.  I reward !!
0
Comment
Question by:pmelkebeke
  • 2
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
samopal earned 220 total points
ID: 2542935
You can check a mouse activity in Timer event

In Module

Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long

Public Type POINTAPI
    X As Long
    Y As Long
End Type

       
Public Sub GetMousePos(GetX As Long, GetY As Long)
    Dim n As POINTAPI
    GetCursorPos n
    GetX = n.X
    GetY = n.Y
End Sub

In Form
'add TextBox and Timer on the form
'Text1.value - number of seconds
'Timer1.Interval=1000 (1sec)

Private Sub Timer1_Timer()
   static aX as long, aY as long
   static TimSec as long
   Dim x as long, y as long
   
   GetMousePos x,y
   if x=aX and y=aY then
      TimSec=TimSec+1
      if TimSec > Text1.Value Then
         Timer1.enabled=false
' do what you want to do
          Timer1.enabled=True
          TimSec=0
      end if
   else
      aX=x
      aY=y
      TimSec=0
   end if
End Sub

HTH
0
 
LVL 6

Expert Comment

by:DrDelphi
ID: 2542946
Here's one way:


Dim SecsElapsed As Integer

Private Sub Form_Load()
SecsElapsed = 0
Timer1.Enabled = True
Timer1.Interval = 1000
End Sub

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
Call Reset_Timer
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
Call Reset_Timer
End Sub

Private Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Call Reset_Timer
End Sub

Private Sub Timer1_Timer()
SecsElapsed = SecsElapsed + 1
If SecsElapsed = 5 Then
   MsgBox ("Times up")
   SecsElapsed = 0
End If
DoEvents
Form1.Caption = SecsElapsed
End Sub

Private Sub Reset_Timer()
SecsElapsed = 0

End Sub
0
 

Author Comment

by:pmelkebeke
ID: 2545118
So I would have to write a keydown, keypress and mousemove evnt for every form and every control on that form.  Come on, there has got to be a more easier way, I hope.
0
 
LVL 6

Expert Comment

by:DrDelphi
ID: 2545137
WELL, NO ACTUALLY IF YOU SET THE FORM'S kEYPREVIEW TO TRUE, YOU CAN CUT OUT ALL THE KEYDOWNS AND USE THE KEYDOWN OF THE FORM.AND THE MOUSEMOVE OF THE FORM WILL CATCH MOST OF THE OTHER ACTIVITY, MAKING THE PLACES THAT YOU WILL NEED TO ADD THIS CALL TO RESET_TIMER ONLY THE MOUSEMOVES OF TEXTBOXES, ETC... AND YOU WILL PROBABLY HAVE KEYBOARD ACTIVITY THERE ANYWAY (AFTER ALL, THEY ARE TEXTBOXES! ) <G>

GOOD LUCK!!

PS.. SORRY ABOUT THE CAPS... MY KEYBOARD GOT STUCK!
0
 

Author Comment

by:pmelkebeke
ID: 2545228
I hoped there would be a more easier way to do this, but seems not.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MS Date Picker 64 bit 32 bit issue 12 61
Child Form in front 4 49
Advice in Xamarin 21 97
How to read File Date Created using VB6 8 52
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question