diff --git a/actors/src/UDSActorUser.py b/actors/src/UDSActorUser.py index c9383650..f218e0a0 100644 --- a/actors/src/UDSActorUser.py +++ b/actors/src/UDSActorUser.py @@ -57,7 +57,7 @@ doLogoff = False def sigTerm(sigNo, stackFrame): if trayIcon: - trayIcon.quit() + trayIcon.quit(extra=" (by sigterm)") # About dialog diff --git a/actors/src/udsactor/windows/operations.py b/actors/src/udsactor/windows/operations.py index 9ad9368d..9d11d023 100644 --- a/actors/src/udsactor/windows/operations.py +++ b/actors/src/udsactor/windows/operations.py @@ -208,14 +208,20 @@ def initIdleDuration(atLeastSeconds): def getIdleDuration(): - lastInputInfo = LASTINPUTINFO() - lastInputInfo.cbSize = ctypes.sizeof(lastInputInfo) - if ctypes.windll.user32.GetLastInputInfo(ctypes.byref(lastInputInfo)) == 0: + try: + lastInputInfo = LASTINPUTINFO() + lastInputInfo.cbSize = ctypes.sizeof(lastInputInfo) + if ctypes.windll.user32.GetLastInputInfo(ctypes.byref(lastInputInfo)) == 0: + return 0 + if lastInputInfo.dwTime > 1000000000: # Value toooo high, nonsense... + return 0 + millis = ctypes.windll.kernel32.GetTickCount() - lastInputInfo.dwTime # @UndefinedVariable + if millis < 0: + return 0 + return millis / 1000.0 + except Exception as e: + logger.error('Getting idle duration: {}'.format(e)) return 0 - if lastInputInfo.dwTime > 1000000000: # Value toooo high, nonsense... - return 0 - millis = ctypes.windll.kernel32.GetTickCount() - lastInputInfo.dwTime # @UndefinedVariable - return millis / 1000.0 def getCurrentUser():