def get_startbutton(self): """ Finds the startbutton """ try: desktop = win32gui.GetDesktopWindow() return Window(win32gui.FindWindowEx(desktop ,None ,"button" , None )) except win32gui.error: logging.exception("Error while finding the startbutton") return None
def start(self): "start the listeners with a safety try/finally to unregister keys and kill the icon" self.notifyicon.show_balloon("Go!", "PWT") #Do an initial lookup of all the windows and tile accordingly for monitor in self.monitors: monitor.tilers[ self.group].windows = Window.valid_windows_from_monitor( monitor) monitor.tilers[self.group].tile_windows() try: #message priming read message = self.notifyicon.windowmessage while message: #if message is WM_HOTKEY if message[1][1] == WM_HOTKEY: #execute the corresponding hotkeycmd using the id self.notifyicon.hotkeys[message[1][2] - 1].execute() #if lparam is an add event elif message[1][2] in self.ADD_EVENTS: window = Window(message[1][3]) if window not in self.current_group_windows: self.current_tiler.add_window(window) #if lparam is a remove event elif message[1][2] in self.REMOVE_EVENTS: self.handle_remove_event( Window(message[1][3]), Monitor.monitor_from_point_in_list( self.monitors, message[1][5])) if self.stop: self.notifyicon.show_balloon("Stop!", "PWT") break #Grab the next message from the message queue message = self.notifyicon.windowmessage finally: #Unregister hotkeys and shellhook self.notifyicon.unregister_shellhook() self.notifyicon.unregister_hotkeys() #Decorate windows self.decorate_all_tiledwindows() #make sure the taskbar is shown on exit self.taskbar.show() #Remove icon self.notifyicon.destroy()