|
-
Jun 1st, 2000, 07:03 AM
#1
Thread Starter
Junior Member
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.
-
Jun 1st, 2000, 07:06 AM
#2
Put a Function to reset the Timer in the Form's MouseMove and KeyPress events.
-
Jun 1st, 2000, 07:13 AM
#3
PowerPoster
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.
-
Jun 1st, 2000, 07:22 AM
#4
Thread Starter
Junior Member
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.
-
Jun 1st, 2000, 08:54 AM
#5
Junior Member
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)
-
Jun 1st, 2000, 09:04 AM
#6
Thread Starter
Junior Member
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.
-
Jun 1st, 2000, 09:52 AM
#7
Junior Member
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)
-
Jun 1st, 2000, 10:59 AM
#8
PowerPoster
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
-
Jun 2nd, 2000, 10:20 AM
#9
Thread Starter
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|