Beispiel #1
0
def move_current_window_to_desktop(n=1, follow=False):
    window_handle = Window.get_foreground().handle
    pyvda.MoveWindowToDesktopNumber(window_handle, n)
    if follow:
        go_to_desktop_number(n)
Beispiel #2
0
def move_current_to_n(n=0, follow=False):
    wndh = ui.active_window().id
    pyvda.MoveWindowToDesktopNumber(wndh, n)
    if follow:
        pyvda.GoToDesktopNumber(n)
Beispiel #3
0
 def workspace_move(n: int):
     """Close the current window"""
     wndh = ui.active_window().id
     pyvda.MoveWindowToDesktopNumber(wndh, n)
     pyvda.GoToDesktopNumber(n)
Beispiel #4
0
#use 32 bit python
#https://github.com/mrob95/py-VirtualDesktopAccessor
import pyvda
import win32gui

number_of_active_desktops = pyvda.GetDesktopCount()
current_desktop = pyvda.GetCurrentDesktopNumber()

current_window_handle = win32gui.GetForegroundWindow()
pyvda.MoveWindowToDesktopNumber(current_window_handle, 1)

pyvda.GoToDesktopNumber(2)

window_moved_to = pyvda.GetWindowDesktopNumber(current_window_handle)
Beispiel #5
0
NEED_WINDOW_DESKTOP_NUMBER = 2


def get_hwnd_for_pid(pid: int):
    def callback(hwnd: int, hwnds: list):
        if win32gui.IsWindowVisible(hwnd) and win32gui.IsWindowEnabled(hwnd):
            _, found_pid = win32process.GetWindowThreadProcessId(hwnd)
            if found_pid == pid:
                hwnds.append(hwnd)
                return True
        return True

    hwnds = []
    win32gui.EnumWindows(callback, hwnds)
    return hwnds[0] if hwnds else -1


for proc in psutil.process_iter():
    if not proc.is_running() or proc.name() != 'ConEmu.exe':
        continue

    hwnd = get_hwnd_for_pid(proc.pid)

    # If the window is already on the desired desktop
    if hwnd == -1 or pyvda.GetWindowDesktopNumber(hwnd) == NEED_WINDOW_DESKTOP_NUMBER:
        continue

    print(f'Moved window (pid={proc.pid}) to window desktop #{NEED_WINDOW_DESKTOP_NUMBER}')
    pyvda.MoveWindowToDesktopNumber(hwnd, NEED_WINDOW_DESKTOP_NUMBER)