|
-
Mar 26th, 2001, 08:33 PM
#1
Thread Starter
New Member
I am looking for code to return the ammount of time the computer has been idle, I am working on a security program for someone and I want to make it re-activate after a certain ammount of idle time. (kind of like a screen saver)
thx
 ~* Sp1Ral FlAmE *~ & Intrix Software 
-
Mar 26th, 2001, 10:02 PM
#2
Good Ol' Platypus
Use a Do...Loop statement:
Code:
Option Explicit
Dim KeyPressed as Boolean
Dim Rec as PointAPI
...
...
...
Dim A, B, C, D
Dim MS as Long
MS = 300000 '(set for 5 minutes)
A = GetTickCount 'reminder to declare this API
Do
D = CheckInputs
If D <> 0 Then A = D
DoEvents
B = GetTickCount
Loop Until C => MS
Function CheckInputs as Long
Dim Nw as PointAPI
If KeyPressed Then KeyPressed = False
GetCursorPos Nw 'reminder to declare this API
If Rec.X <> Nw.X or Rec.Y <> Nw.Y Then
CheckInputs = GetTickCount
Rec.X = Nw.X: Rec.Y = Nw.Y
End If
End Function
Private Sub Form_KeyDown(.... blah ...)
KeyPressed = True
End Sub
Something along those lines should suit you well. You should put the first two declarations in a module and the second two declarations and the Do...Loop statement in Sub Main. Then you should be sure to show a hidden form (hence the form_keydown) before doing the loop and setting it's keypreview to TRUE. Then put the CheckInputs in the module and set the startup object to sub main. After the loop, make sure to put whatever code you want to execute after the loop.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Mar 28th, 2001, 05:05 AM
#3
This may sound a little odd, but why don't you just make it EXACTLY like a screen saver? All screen savers are are .exe files with the extension changed to .scr. Just make a change to it to not run when the preview window passes it a /p parameter in the command$ string.
-
Mar 28th, 2001, 10:52 AM
#4
Thread Starter
New Member
I had though of that, except I had one form running in the task bar to allow the user to change preferences etc. and when it is time the sercurity form loads. I have never used screen savers that way, although I have done some reading about it. I am trying to keep this as simple as I can because this is just a side project for a friend. I'm going to try the first bit of code and see if it does the trick.
Thx
 ~* Sp1Ral FlAmE *~ & Intrix Software 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|