Esempio n. 1
0
def close():
    set_status(False)
    handle = win32gui.GetForegroundWindow()
    try:
        win32gui.PostMessage(handle,win32con.WM_CLOSE,0,0)
        set_status(True)
    except Exception:
        pass
Esempio n. 2
0
def restore():
    set_status(False)
    handle = win32gui.GetForegroundWindow()
    # ensure window is visible for non-elevated applications:
    win32gui.ShowWindow(handle, win32con.SW_SHOW)   
    result = win32gui.ShowWindow(handle, win32con.SW_RESTORE)
    # If says previously invisible, then we are dealing with an
    # elevated application and have failed:
    set_status(result != 0)  
Esempio n. 3
0
def resize_window(size):
    set_status(False)
    width,height = size.split(",")
    width  = int(width)
    height = int(height)
    handle = win32gui.GetForegroundWindow()
    left, top, right, bottom = win32gui.GetWindowRect(handle)
    win32gui.MoveWindow(handle, left, top, width, height, 1)
    set_status(True)
def list_windows(specification="never match anything 24328#45348932453"):
    set_status(False)
    print
    foreground_window = win32gui.GetForegroundWindow()
    try:
        results = find_windows(make_matcher(".*"), 1000000)
    except Exception, e:
        print "find_windows failed: " + repr(e)
        traceback.print_exc()
        return
def window_go_(specification):
    set_status(False)
    windows = find_windows(make_matcher(specification))
    if len(windows) == 0:
        print "NOT FOUND: " + specification  # <<<>>>
        return
    window = windows[-1]
    print "-> " + format_ID(window)  # <<<>>>
    success = switch_to(window)
    set_status(success)
Esempio n. 6
0
def move_window(position):
    set_status(False)
    x,y = position.split(",")
    x = int(x)
    y = int(y)
    handle = win32gui.GetForegroundWindow()
    left, top, right, bottom = win32gui.GetWindowRect(handle)
    width  = right - left
    height = bottom - top
    win32gui.MoveWindow(handle, x, y, width, height, 1)
    set_status(True)
    try:
        results = find_windows(make_matcher(".*"), 1000000)
    except Exception, e:
        print "find_windows failed: " + repr(e)
        traceback.print_exc()
        return

    for w in results:
        if matches(w, specification):
            out = "*"
        else:
            out = " "
        if w == foreground_window:
            out += ">"
        else:
            out += " "
        out += format_ID(w) + ": " + \
              win32gui.GetWindowText(w) + "|" + \
              win32gui.GetClassName(w)
        try:
            out += "|" + executable_for_window(w)
        except:
            out += "|FAILED"
        print out
    print
    set_status(True)


def matches(window_handle, specification):
    return make_matcher(specification)(window_handle)
Esempio n. 8
0
def maximize():
    set_status(False)
    handle = win32gui.GetForegroundWindow()
    win32gui.ShowWindow(handle, win32con.SW_MAXIMIZE)
    set_status(ctypes.windll.user32.IsZoomed(handle))
Esempio n. 9
0
def minimize():
    set_status(False)
    handle = win32gui.GetForegroundWindow()
    win32gui.ShowWindow(handle, win32con.SW_MINIMIZE)
    set_status(win32gui.IsIconic(handle))