for my "homework" I need to write an application that would log computer idleness to file. Idleness in my case is defined by keyboard inactivity for more than 10 minutes.
So I've created a service to run this system wide. In that service I've put timer and some basic logic.
Logic is really simple:
Expand|Select|Wrap|Line Numbers
- count = 0
- For i As Integer = 7 To Byte.MaxValue - 1
- If GetAsyncKeyState(i) <> 0 Then count += 1
- Next i
- if count > 0 then return true
So where is the problem?
One of my machines are in use by my whole family. It has three user accounts.
Problems begin when more than one user is logged in ... because GetAsyncKeyState returns status only for the user, that logged in first. I believe there are some multiple (currently in use) desktop issues but I just can't find a solution.
Can please anyone help me with how to 'switch' to currently active desktop from service so that GetAsyncKeyState would give me some results.
btw: I have the same problem with GetCursorPos logic ... it just returns x=0, y=0
I'm using win XP SP2 VB.NET2
Thank you for your help,
Damjan