예제 #1
0
def systemIsIdle():
    LastInput = win32api.GetTickCount() - win32api.GetLastInputInfo()
    #print("LastInput %s " % (LastInput))
    #3000 <=> 1 second
    if LastInput > 540000:
        print("System is idle")
        return True
    else:
        return False
예제 #2
0
 def run(self):
     # self.hm.KeyDown = self.KeyboardEvent
     # self.hm.MouseAllButtonsDown = self.MouseButtons
     # self.hm.MouseMove = self.MouseMove
     # self.hm.HookKeyboard()
     # self.hm.HookMouse()
     while True:
         idle_time = (win32api.GetTickCount() -
                      win32api.GetLastInputInfo()) / 1000.0
         if idle_time < 3 * 60:
             # if we are not idle, hit a placeholder key and update the screen
             self.key_hook('placeholder', [], 'a', False)
             window_name = GetWindowText(GetForegroundWindow())
             self.screen_hook(window_name, window_name, 1, 1, 1, 100)
         pythoncom.PumpWaitingMessages()
         time.sleep(5)