def updateTimer(self, event): self.processTimeActive += self.timerDelay / 1000 windowName = win32gui.GetWindowText(win32gui.GetForegroundWindow()) if self.processName == "ERROR-FINDING-PROCESS": try: self.pid = win32process.GetWindowThreadProcessId( win32gui.GetForegroundWindow())[-1] self.processName = psutil.Process(self.pid).name() except: self.processName = "ERROR-FINDING-PROCESS" if self.lastWindowName != windowName: #OutputActivity(startTime, time.time(), lastWindowName, processName) activity = Activity(self.startTime, time.time(), self.lastWindowName, self.processName, self.filePath) activity.SaveToFile() self.startTime = time.time() try: self.pid = win32process.GetWindowThreadProcessId( win32gui.GetForegroundWindow())[-1] self.processName = psutil.Process(self.pid).name() except: self.processName = "ERROR-FINDING-PROCESS" self.lastWindowName = windowName del activity self.processTimeActive = 0 self.updateGUI()