Results 1 to 5 of 5

Thread: mainly gurus but anyone please help!!

  1. #1

    Thread Starter
    Fanatic Member zmerlinz's Avatar
    Join Date
    May 2000
    Location
    in a world where the sun always shines on the bloody tv!!
    Posts
    604

    Angry

    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]

  2. #2
    Guest
    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

  3. #3

    Thread Starter
    Fanatic Member zmerlinz's Avatar
    Join Date
    May 2000
    Location
    in a world where the sun always shines on the bloody tv!!
    Posts
    604
    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]

  4. #4
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    Auckland, NZ
    Posts
    411

    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
    Paul Lewis

  5. #5

    Thread Starter
    Fanatic Member zmerlinz's Avatar
    Join Date
    May 2000
    Location
    in a world where the sun always shines on the bloody tv!!
    Posts
    604
    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
  •  



Click Here to Expand Forum to Full Width