Thanks, keep in note of the version i am using...
Visual Basic Idle Time
#1
Posted 21 July 2007 - 06:58 AM
Thanks, keep in note of the version i am using...
#2
Posted 21 July 2007 - 10:16 AM
1. Have a timer object and have the interval length set at whatever amount of time you want to be the point where you consider the computer to be idle. (ie. 5 mins... though it must be done in milliseconds... so that would be 30000 i believe)
2. At the timer's tick event, have the program do whatever you want it to do when the computer is idle.
3. But, (this is where we check for if the computer is actually idle) also have KeyPress and MouseMove (and maybe MouseClick... I mean it is possible for someone to click without moving their mouse...) events, and if either of them occur, stop the timer, then start it again.
If you need more explaining or maybe an example (of code), feel free to ask. Hopefully this is a good starting point for you to do what you want.
Edited by stettybet0, 21 July 2007 - 10:17 AM.
#3
Posted 21 July 2007 - 10:24 AM
Er, however, ive been experiencing problems on finding a method to detect whether a mouse has been moved in express 2005...
Also, is there is another method for detecting key presses besides looping through every key available to check their state? If not, its ok, just saves time really...
Thanks for replying. Oh and i do have basic knowledge of VB.
PS. The other main problem is that this program will be a background process (no its nothing like a keylogger, it just times your idle time for a website)
EDIT: More onto this lil subject.. , er i'd need to have 2 timers right? 1 like you said and 1 that keeps checking movement because by what your saying, wouldnt the detection only be every 5 minutes?
Edited by BirdieUK, 21 July 2007 - 10:32 AM.
#4
Posted 21 July 2007 - 10:34 AM
Er, however, ive been experiencing problems on finding a method to detect whether a mouse has been moved in express 2005...
Under your form events, the MouseMove event should detect if the mouse has been moved.
Also, is there is another method for detecting key presses besides looping through every key available to check their state? If not, its ok, just saves time really...
Again, under form event, the KeyPress event should detect if any key has been pressed.
So here's an example: (The form is called "Idle", and the timer is called "Timer".)
Public Class Idle Private Sub Idle_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'You should have already set the interval in the designer... Timer.Start() End Sub Private Sub Idle_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress Timer.Stop() Timer.Start() End Sub Private Sub Idle_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove Timer.Stop() Timer.Start() End Sub Private Sub Idle_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick Timer.Stop() Timer.Start() End Sub Private Sub Timer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer.Tick Application.Exit() 'I just have the program exiting, though you could have it do whatever you want. End Sub End Class
Edit: Oh, and 5 mins would equal 300000 milliseconds, not 30000.
Edited by stettybet0, 21 July 2007 - 10:40 AM.
#5
Posted 21 July 2007 - 10:47 AM
Feels weird getting helped on something like this by a guy my age :\
1 quick question though, the events such as keypress,etc. only work when its focused on the form? Is there a way past this? Sorry if this sounds like your spoonfeeding me all of this, i hate being in this situation lol.
Edited by BirdieUK, 21 July 2007 - 10:53 AM.
#6
Posted 21 July 2007 - 10:53 AM
Well, glad I could help.
Edit: saw your edit... alright... that is a bit of a problem... I don't have much experience with making programs which run in the background, and I'm not sure how we could get it to capture input on anything (other than itself). I think it might involve an API call to detect the actual input of the keyboard and mouse to the computer, but I'm not sure how to do that off the top of my head... I'll try to get back to you after I've done a little research.
Edited by stettybet0, 21 July 2007 - 10:58 AM.
#7
Posted 21 July 2007 - 11:49 AM
I'll try some other forums also to see if anyone can bring some light into this. I'll keep an eye on this in case you find something
Similar Topics
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users