Reset System Idle Time?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • twinnyfo
    Recognized Expert Moderator Specialist
    • Nov 2011
    • 3664

    Reset System Idle Time?

    Is it possible for VBA to reset the System Idle time, so that while your DB is open, but idle, the code can routinely reset the system idle time, so that the screensaver does not activate, and thus break all network conneections, causing Access to have errors?

    Our systems at work do not allow deactivating screensavers, so this would be a workaround.....
  • Seth Schrock
    Recognized Expert Specialist
    • Dec 2010
    • 2965

    #2
    I have left my databases open all night with my computer locked and screensaver on and it doesn't break the network connection. In fact, the network connection on all of our computers at work remain up while they are in screensaver. I'm guessing that there is a different problem causing the issue. Not knowing at what time of day the break, is it possible that the user is setup to not be able to login to the network during certain times? Even if the user is logged in over this time, it will break the connection to the network shares, causing the database to disconnect.

    Comment

    • twinnyfo
      Recognized Expert Moderator Specialist
      • Nov 2011
      • 3664

      #3
      Our computers break the DB network connections just about every time the screensaver activates or when they fall asleep. This doesn't seem to affect some applications, like Outlook, but I have noticed that if my computer falls asleep and then I wake it up, it will take a while for Outlook to refresh and become fully functional.

      Our DB is used while we are reviewing paper records and annotating discrepancies in the DB. Sometimes, the paper review may take longer than the required screensaver timeout and the network connection will be broken. This is why I am trying to reset the system idle time. If the system think that it has only ben 60 seconds since the last activity (instead of 10 minutes), it will not activate the screensaver, thus allowing the network connections to stay alive.

      Comment

      • Seth Schrock
        Recognized Expert Specialist
        • Dec 2010
        • 2965

        #4
        My last guess would be to check the group policy in active directory to see if there is a policy to disable the NIC or maybe disconnect from the network shares when in screensaver. I don't know how to reset the idle timer using VBA.

        Comment

        • twinnyfo
          Recognized Expert Moderator Specialist
          • Nov 2011
          • 3664

          #5
          Seth,

          That's the issue exactly. Our network group policies are managed very tightly, so other than connecting the mice to perpetual motion machines driven by hamsters in a wheel, I'm looking for system events that could be either turned off (which our group policy would not allow), or "tricked" into thinking something else is going on.

          Thanks for your thoughts......

          Comment

          • zmbd
            Recognized Expert Moderator Expert
            • Mar 2012
            • 5501

            #6
            Using the ontimer event to open a shell object, use the sendkeys to the object and then close the object... my thought is that the sendkeys is supposed to act as though someone is sitting at the keyboard typing the info; thus, reseting the PC idle... otherwise we may be looking at an API call.
            http://forum.sysinternals.com/how-to...opic16362.html talks about this; however, I rarely use api calls; thus, I wouldn't know how to get at this one.... someone out there does though.

            -z

            -z
            Last edited by zmbd; Aug 30 '12, 02:28 PM.

            Comment

            • twinnyfo
              Recognized Expert Moderator Specialist
              • Nov 2011
              • 3664

              #7
              Z-

              You set me to thinking with this...

              Here is a function I can declare to get the amount of time it was since the user last input any information:

              Code:
              Private Declare Function GetTickCount Lib "kernel32" () As Long
              Private 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
              Then, in the Timer event of my form that typically stays open for hours, sometimes with little input, I put this little bit of code:

              Code:
                  If Not GetUsersIdleTime() < 250 Then
                      SendKeys "A"
                      SendKeys "{BS}"
                  End If
              The 250 value is less than half of our mandatory screensaver timeout time of ten minutes (600 seconds). Now, if someone is using the db, the GetUsersIdleTim e value will be very small. However, if they are ignoring the db for a few minutes, this code will send a letter, then backspaces over it.

              This may do the trick -- I'll have to test it live, though and will get back with the results!
              Last edited by twinnyfo; Aug 30 '12, 04:53 PM. Reason: adjusted idle timer settings

              Comment

              • Rabbit
                Recognized Expert MVP
                • Jan 2007
                • 12517

                #8
                If this works, and I don't know if it will because I think the system would make a distinction between real user input and automated input, but if it does work, I would send a more benign key like the alt key.

                Comment

                • twinnyfo
                  Recognized Expert Moderator Specialist
                  • Nov 2011
                  • 3664

                  #9
                  Good point Rabbit! My code has been changed accordingly...

                  Comment

                  • twinnyfo
                    Recognized Expert Moderator Specialist
                    • Nov 2011
                    • 3664

                    #10
                    And, it does appear that the computer can, indeed, tell the difference between SendKeys and actual user input...... Grrrrrrr!!!

                    Any other thoughts from anyone???

                    Comment

                    • zmbd
                      Recognized Expert Moderator Expert
                      • Mar 2012
                      • 5501

                      #11
                      here's a method:

                      -z

                      Comment

                      • twinnyfo
                        Recognized Expert Moderator Specialist
                        • Nov 2011
                        • 3664

                        #12
                        Okay---

                        I shortened up all the wait times and timer interval is set at 60000 (60 seconds)

                        Thenin the TImer Event this (thanks for the advice Rabbit):

                        Code:
                            If GetUsersIdleTime() >= 59 Then
                                SendKeys "+"
                            End If
                        If the user has not touched the machine in the last 59 seconds, SendKeys fires.

                        Suring testing, my machine stayed awake for 30 minutes (a new world record in this office!!)

                        Maybe others can use this little trick.......... ..

                        Comment

                        Working...