|
-
Sep 22nd, 2000, 02:29 PM
#1
Thread Starter
Fanatic Member
hi,
does anyone know a way to check for harddrive inactivity for a set period time of 15mins (excluding screen saver)
then unload my program
thanks to anyone who can help me
please include code
Cheers
Merlin ?
Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
-- Linus Torvalds
[ Galahtech.com] | [ My Site] | [ Fishsponge] | [ UnixForum.co.uk]
-
Sep 22nd, 2000, 02:58 PM
#2
Add the following to a Form with a Timer.
Code:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
X As Long
Y As Long
End Type
Dim CurPos As POINTAPI
Dim OldX As Single
Dim OldY As Single
Dim StartTime As Date
Sub Start()
'Create a StartTime
StartTime = Format(Time, "hh:mm:ss")
End Sub
Private Sub Form_Load()
'Give a StartTime when the Form loads
Start
Timer1.Interval = 1
End Sub
Private Sub Timer1_Timer()
'Loop through the keys and see if they were pressed
For I = 32 To 127
If GetAsyncKeyState(I) Then Start
'Do the same for the Mouse Buttons
If GetAsyncKeyState(vbLeftButton) Then Start
If GetAsyncKeyState(vbRightButton) Then Start
Next
'Check if mouse is still
MyPos = GetCursorPos(CurPos)
X = CurPos.X
Y = CurPos.Y
If OldX = X And OldY = Y Then
'The mouse is still
Else
'the Mouse is not still
OldX = X
OldY = Y
'Create a new StartTime
Start
End If
'Subtract the current time with the StartTime
Retval = StartTime - Time
Retval = Format(Retval, "hh:mm:ss")
'If it's been 15 min then unload the form
If Retval = "00:15:00" Then
Unload Me
'Create a new StartTime
Start
End If
End Sub
-
Sep 23rd, 2000, 04:06 AM
#3
Thread Starter
Fanatic Member
cheers megatron that was very useful.
Merlin ?
Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
-- Linus Torvalds
[ Galahtech.com] | [ My Site] | [ Fishsponge] | [ UnixForum.co.uk]
-
Sep 23rd, 2000, 05:16 AM
#4
Hyperactive Member
How does it work?
Megatron,
How does your code test for hard drive inactivity?
It seems to only check if a key is pressed or mouse is moved.
Cheers
-
Sep 23rd, 2000, 11:38 AM
#5
Thread Starter
Fanatic Member
i agree with Paul here, how does it work Megatron ?
Merlin ?
Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
-- Linus Torvalds
[ Galahtech.com] | [ My Site] | [ Fishsponge] | [ UnixForum.co.uk]
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
|