Results 1 to 9 of 9

Thread: key press and mouse movement

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2000
    Posts
    20
    I'm writing program that will automatically 'do something' if the pc has been idle for a certain about of time, sort of like and screen saver.. But this is where I get stuck, how can I make my program know when a key is pressed or the mouse has been moved, so that the idle timer can be restarted.
    note: The program will be hidden since its going to be like an screen saver.
    not all police eat doughnut's and drink coffee.. some of us like milk instead.

  2. #2
    Guest
    Put a Function to reset the Timer in the Form's MouseMove and KeyPress events.

  3. #3
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Exclamation

    Since the PC is in Idle mode, The MouseMove and KeyPress events may not work although we really move it. It must something deal with the API function call.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Feb 2000
    Posts
    20
    But in order to use the form MouseMove and KeyPress, you'll have to do that on the from.. That won't be possible since the form is hidden. I know it has something to do with subclassing and api calls, but which ones?
    not all police eat doughnut's and drink coffee.. some of us like milk instead.

  5. #5
    Junior Member
    Join Date
    May 2000
    Location
    New Delhi, India
    Posts
    18

    Question Screen Saver?

    Hi
    Are you creating Screen Saver? If so, there is a special way to do it. Just put the string SCRNSAVE: prefix to the Application title dialog box in VB. Compile as .scr file. Windows will run your application.

    The matter of terminating the screen saver is easy. Ignore the first MouseMove event and KeyDown Event.

    Hope it works!
    Kazim Zaidi (the cracker)

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Feb 2000
    Posts
    20
    I'm not trying to make a screen saver, just an app that would 'do something' of the pc has been idle for a certain amount of time.. But I'm tying to reset the idle time on the program of a key is pressed or if the mouse is moved at anytime, even if my program isn't visable [the from is hidden, so I know I can't use KeyPress or MouseMove]
    not all police eat doughnut's and drink coffee.. some of us like milk instead.

  7. #7
    Junior Member
    Join Date
    May 2000
    Location
    New Delhi, India
    Posts
    18

    Lightbulb Use API

    I suggest you to use mouse_event and keybd_event API Calls. These are called when the user moves mouse or press a key. They also let you Move the mouse.
    Kazim Zaidi (the cracker)

  8. #8
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Thumbs up GetKeyState API

    Hi nopd-officer, Finally I manage to get you a solution but may not be a good solution. Whereby, you need to use a Timer (set the interval to 250ms. If you nedd a faster respond) and GetKeyState API function as below:

    But, this code have a defact, where the user need to hold the Esc key at least 500ms.

    Code:
    Option Explicit
    Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
    Private Const VK_ESCAPE = &H1B
    Private Sub Form_Load()
    Me.Hide
    Timer1.Enabled = True
    End Sub
    
    Private Sub Timer1_Timer()
    If GetKeyState(VK_ESCAPE) < 0 Then
        Me.Show
        Timer1.Enabled = False
    End If

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Feb 2000
    Posts
    20
    Thanks.. I messed around with some things and got it to work
    not all police eat doughnut's and drink coffee.. some of us like milk instead.

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