def shift_focused_window_up(self):
        """
        Switches the window to the previous position
        """

        window = Window.focused_window()

        #only grab and move the window if it is in the self
        if window in self.windows:

            i = self.windows.index(window)

            #if the foreground window is first, shift everything and place it last
            if i == 0:

                j = len(self.windows) - 1
                self.windows[j], self.windows[:j] = self.windows[0], self.windows[1:]

            #else shift it with the trailing window
            else:

                j = i - 1
                self.windows[i], self.windows[j] = self.windows[j], self.windows[i]

            self.tile_windows()

            if not window.focus():

                self.remove_window(window)
    def cmd_print_focused_window_classname(self):

        win32clipboard.OpenClipboard()
        win32clipboard.EmptyClipboard()
        win32clipboard.SetClipboardText(Window.focused_window().classname)
        win32clipboard.CloseClipboard()

        print(Window.focused_window().classname)
    def shift_focused_window_down(self):
        """
        Switches the window to the next position
        """
        
        #get focused window
        window = Window.focused_window()

        #only grab and move the window if it is in the self
        if window in self.windows:

            i = self.windows.index(window)

            #if the foreground window is the last window, shift everything and place it first
            if i == len(self.windows) - 1:

                self.windows[0], self.windows[1:] = self.windows[i], self.windows[:i]

            #else shift it with the following window
            else:

                self.windows[i], self.windows[i+1] = self.windows[i+1], self.windows[i]

            self.tile_windows()

            if not window.focus():

                self.remove_window(window)
 def cmd_toggle_tiled_floating(self):
     win = Window.focused_window(self.windows)
     if(win != None):
         if(win.floating):
             win.tile()
         else:
             win.float()
    def shift_focused_window_down(self):
        """
        Switches the window to the next position
        """

        #get focused window
        window = Window.focused_window()

        #only grab and move the window if it is in the self
        if window in self.windows:

            i = self.windows.index(window)

            #if the foreground window is the last window, shift everything and place it first
            if i == len(self.windows) - 1:

                self.windows[0], self.windows[1:] = self.windows[
                    i], self.windows[:i]

            #else shift it with the following window
            else:

                self.windows[i], self.windows[i + 1] = self.windows[
                    i + 1], self.windows[i]

            self.tile_windows()

            if not window.focus():

                self.remove_window(window)
    def next_layout(self):
        """
        Switch to the next layout
        """
        
        nextLayout = Utility.next_item(self.layouts, self.currentLayout) 

        if nextLayout: 

            self.currentLayout = nextLayout

        self.masterarea = self.currentLayout.maxSize // 2

        self.tile_windows()

        if not Window.focused_window().center_cursor():

            self.remove_window(Window.focused_window())
    def cmd_send_to_group_9(self):

        if self.group != 8:

            window = Window.focused_window() 

            if window:

                self.send_window_to_tiler(window, 8)
    def switch_group(self, i):
        "Switch the current group into group i"
        
        for monitor in self.monitors:

            for window in monitor.tilers[self.group].windows:

                window.hide()
            
            for window in monitor.tilers[i].windows:

                window.show()

            monitor.tilers[i].tile_windows()

        self.group = i
        self.notifyicon.draw_icon(self.icon)

        Window.window_under_cursor().focus()
 def cmd_move_to_next_monitor(self):
     window = Window.focused_window(self.windows)
     # if(window.validate()):
     monitor = Monitor.monitor_from_window_in_list(self.monitors, window)
     nextMonitor = Utility.next_item(self.monitors, monitor)
     if(monitor != nextMonitor):
         tiler = monitor.tilers[self.group]
         nextTiler = nextMonitor.tilers[self.group]
         tiler.remove_window(window)
         nextTiler.add_window(window)
         window.focus()
 def cmd_move_to_previous_monitor(self):
     window = Window.focused_window(self.windows)
     # if(window.validate()):
     monitor = Monitor.monitor_from_window_in_list(self.monitors, window)
     previousMonitor = Utility.previous_item(self.monitors, monitor)
     if(monitor != previousMonitor):
         tiler = monitor.tilers[self.group]
         previousTiler = previousMonitor.tilers[self.group]
         tiler.remove_window(window)
         previousTiler.add_window(window)
         window.focus()
Beispiel #11
0
    def __init__(self):

        #taskbar
        self.taskbar = Window.find_window("Shell_TrayWnd")
        self.startbutton = self.get_startbutton()

        self.appbarData = APPBARDATA(ctypes.sizeof(APPBARDATA)
                ,self.taskbar.hWindow
                ,0
                ,0
                ,RECT(0,0,0,0)
                ,0
        )
Beispiel #12
0
    def __init__(self):

        #taskbar
        self.taskbar = Window.find_window("Shell_TrayWnd")
        self.startbutton = self.get_startbutton()

        self.appbarData = APPBARDATA(ctypes.sizeof(APPBARDATA)
                ,self.taskbar.hWindow
                ,0
                ,0
                ,RECT(0,0,0,0)
                ,0
        )
    def focus_next(self):
        """
        Sets focus on the next window
        """

        window = Utility.next_item(self.windows, Window.focused_window())

        if window:

            if not window.focus():

                self.remove_window(window)

        else:

            self.focus_primary()
    def focus_next(self):
        """
        Sets focus on the next window
        """

        window = Utility.next_item(self.windows, Window.focused_window())

        if window:            
            
            if not window.focus():

                self.remove_window(window)

        else:

            self.focus_primary()
    def focus_previous(self):
        """
        Sets focus on the previous window
        """

        #get focused window
        window = Utility.previous_item(self.windows, Window.focused_window())

        if window: 

            if not window.focus():

                self.remove_window(window)

        else:

            self.focus_primary()
    def focus_previous(self):
        """
        Sets focus on the previous window
        """

        #get focused window
        window = Utility.previous_item(self.windows, Window.focused_window())

        if window:

            if not window.focus():

                self.remove_window(window)

        else:

            self.focus_primary()
Beispiel #17
0
    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:
            windows = Window.valid_windows_from_monitor(monitor)
            for window in windows:
                self.add_window(monitor.tilers[self.group], window)
            monitor.tilers[self.group].tile_windows()

        try:
            # message priming read
            message = self.notifyicon.windowmessage

            while message:
                if message[1][1] == WM_HOTKEY:
                    # if message is WM_HOTKEY
                    # execute the corresponding hotkeycmd using the id
                    self.notifyicon.hotkeys[message[1][2]-1].execute()
                elif message[1][2] in self.ADD_EVENTS:
                    # if lparam is an add event
                    window = Window(message[1][3])
                    self.add_window(self.current_tiler, window)
                elif message[1][2] in self.REMOVE_EVENTS:
                    #if lparam is a remove event
                    self.handle_remove_event(message[1][3], Monitor.monitor_from_point_in_list(
                        self.monitors, message[1][5]))
                if self.stop:
                    self.notifyicon.show_balloon('Stopping!', 'PWT')
                    break

                # Grab the next message from the message queue
                message = self.notifyicon.windowmessage
        except:
            logging.exception('Exception occurred')

        self.notifyicon.unregister_shellhook()  # Unregister shellhook
        self.notifyicon.unregister_hotkeys()    # Unregister hotkeys
        self.decorate_all_tiled_windows()   # Decorate windows
        self.taskbar.show()                 # make sure the taskbar is shown on exit
        self.notifyicon.destroy()           # Remove icon
    def make_focused_primary(self):
        """
        Moves the focused window to the first place in the masterarea
        """

        window = Window.focused_window()

        #only move the focused window if it is in the tiler
        if window in self.windows:

            i = self.windows.index(window)

            windowrest = self.windows[:i]
            windowrest.extend(self.windows[i+1:])

            #shift window location
            self.windows[0], self.windows[1:] = self.windows[i], windowrest 
            self.tile_windows()

            if not window.focus():

                self.remove_window(window)
    def cmd_shift_to_previous_monitor(self):

        window = Window.focused_window()

        if window.validate():

            monitor = Monitor.monitor_from_window_in_list(self.monitors, window) 
            previousMonitor = Utility.previous_item(self.monitors, monitor)

            if previousMonitor:
                
                tiler = monitor.tilers[self.group]
                previousTiler = previousMonitor.tilers[self.group]

                if window in tiler.windows:

                    tiler.remove_window(window)

                if window not in previousTiler.windows:

                    previousTiler.add_window(window)

                window.focus()
    def cmd_shift_to_next_monitor(self):

        window = Window.focused_window()

        if window.validate():

            monitor = Monitor.monitor_from_window_in_list(self.monitors, window) 
            nextMonitor = Utility.next_item(self.monitors, monitor)

            if nextMonitor:
                
                tiler = monitor.tilers[self.group]
                nextTiler = nextMonitor.tilers[self.group]

                if window in tiler.windows:

                    tiler.remove_window(window)

                if window not in nextTiler.windows:

                    nextTiler.add_window(window)

                window.focus()
    def cmd_tile_focused_window(self):

        self.current_tiler.tile_window(Window.focused_window())
 def cmd_close_focused_window(self):
     window = Window.focused_window(self.windows)
     window.container.container.remove_window(window)
     window.close()
    def cmd_toggle_focused_window_decoration(self):

        Window.focused_window().toggle_decoration()
 def cmd_send_to_group_9(self):
     if(self.group != 8):
         window = Window.focused_window(self.windows) 
         if(window):
             self.send_window_to_tiler(window, 8)
    def cmd_close_focused_window(self):

        Window.focused_window().close()
 def cmd_toggle_stacked_column(self):
     win = Window.focused_window(self.windows)
     if(win != None and win.container.toggle_stacking()):
         win.container.container.container.tile_windows()
 def cmd_print_focused_window_classname(self):
     class_name = Window.focused_window(self.windows).classname
     self.notifyicon.show_balloon(class_name, 'PWT2')
     logging.debug(class_name)
     print(class_name)
 def cmd_focus_down(self):
     curr_win = Window.focused_window(self.windows)
     # if(curr_win == None):
         # curr_win = self.windows.values()[0]
     if(curr_win != None):
         curr_win.change_focus_down()
    def cmd_float_focused_window(self):

        self.current_tiler.float_window(Window.focused_window())
    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()
 def cmd_move_window_down(self):
     curr_win = Window.focused_window(self.windows)
     if(curr_win != None):
         curr_win.move_down()