Results 1 to 3 of 3

Thread: Do computers dream of electric sheep?

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2000
    Posts
    52

    Post

    And if they do, how could you tell? How can you determine when your computer is sleeping?

    What I'm looking for is how to check if the system has been inactive for a certain period of time. In other words, how can you tell if there hasn't been any mouse or keyboard events? How do screen savers get the this system status info?

    Or, alternatively, is there an easy way to monitor when a keyboard or mouse event has occurred? I know you have to use system hooks to actually process those events from other applications if your program doesn't have the focus, but what if you just need to know when an event has happened, without even needing to know what it was?

    Does anyone know a way to do this without the complications of learning how to set system hooks?

  2. #2
    Addicted Member Razzle's Avatar
    Join Date
    Jan 2000
    Location
    Berlin, Germany
    Posts
    161

    Post

    The only sure thing I know about Windows Hooks is that that don't work systemwide with VB.
    If you want to know, if the mouse hasn't been moved for some time, you can try this:

    Code:
    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    Private Type POINTAPI
            x As Long
            y As Long
    End Type
    Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
    Dim cor As POINTAPI
    Private Sub Form_Load()
    GetCursorPos cor
    Timer1.Intervall = 15000 
    End Sub
    
    Private Sub Timer1_Timer()
    Dim cor2 As POINTAPI
    
    GetCursorPos cor2
    If cor.x = cor2.x Or cor.y = cor2.y Then
    
    'Mouse has not been moved since Timerintervall
    
    End If
    GetCursorPos cor
    End Sub
    Razzle
    ICQ#: 31429438
    What is the difference between a raven?
    -The legs. The length is equal, especially the right one.

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2000
    Posts
    52

    Post

    Hey, that's pretty neat. Now if I can just find a similar way to deal with Keyboard events...

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