OK Race fans, here's a whacky one:
In a separate module, I have these declarations:
These allow me to check whether someone has been using their machine and how long the system has been idle.
In the Timer Event of a form, set to 60,000 (60 seconds), I have this code:
What this does, and it works rather well, is it checks to see if the user has been active on the computer within the last 59 seconds. If not, it "types" a keystroke, in this case, it simulates hitting and releasing the Ctrl-Key. This prevents our screen savers from activating, thus breaking our network connections with the database. Our users will often have to review documents while the DB sits idle. This saves a lot of headaches, and some of you may be familiar with some of my recent posts conerning this.
Here is the issue: When I open this form, when the SendKeys statement activates, the NumLock status automatically turns OFF (it never turns itself back on, but must be turned on manually). This is a real pain, because this form uses the SSN of a person to search, so we often don't realize the NumLock is off until after we start keying in the number. (I have also simulated the Shift Key--"+" with similar results).
This is not a huge deal, but it is really annoying. This is the only thing that has changed on our machines, and it MUST be the form, because when I've opened the form and just let it sit, the NumLock turns off at exactly 60 seconds! (although not all the time--even stranger!)
Any thoughts or ideas on why this is happening and a way to prevent it from happening? Perhaps checking and resetting NumLock status--which I don't know how to do....
I am open to any ideas.
Thanks!
In a separate module, I have these declarations:
Code:
Option Compare Database Option Explicit Public Declare Function GetTickCount Lib "kernel32" () As Long Public Declare Function GetLastInputInfo Lib "user32" (pLII As Any) As Long Private Type LastInputInformation cbSize As Long dwTime As Long End Type Public Function GetUsersIdleTime() As Long Dim LII As LastInputInformation LII.cbSize = Len(LII) Call GetLastInputInfo(LII) GetUsersIdleTime = FormatNumber((GetTickCount() - LII.dwTime) / 1000, 2) End Function
In the Timer Event of a form, set to 60,000 (60 seconds), I have this code:
Code:
Private Sub Form_Timer() On Error GoTo EH If GetUsersIdleTime() >= 59 Then SendKeys "^" End If Exit Sub EH: MsgBox "There was an error with the Timer! Please contact your Database Administrator.", vbCritical, "Error!" Exit Sub End Sub
Here is the issue: When I open this form, when the SendKeys statement activates, the NumLock status automatically turns OFF (it never turns itself back on, but must be turned on manually). This is a real pain, because this form uses the SSN of a person to search, so we often don't realize the NumLock is off until after we start keying in the number. (I have also simulated the Shift Key--"+" with similar results).
This is not a huge deal, but it is really annoying. This is the only thing that has changed on our machines, and it MUST be the form, because when I've opened the form and just let it sit, the NumLock turns off at exactly 60 seconds! (although not all the time--even stranger!)
Any thoughts or ideas on why this is happening and a way to prevent it from happening? Perhaps checking and resetting NumLock status--which I don't know how to do....
I am open to any ideas.
Thanks!
Comment