Ejemplo n.º 1
0
def get_office_window(hwnd, lparam):
    if USER32.IsWindowVisible(hwnd):
        text = create_unicode_buffer(1024)
        USER32.GetWindowTextW(hwnd, text, 1024)
        # TODO Would " - Microsoft (Word|Excel|PowerPoint)$" be better?
        if re.search("- (Microsoft|Word|Excel|PowerPoint)", text.value):
            USER32.SendNotifyMessageW(hwnd, WM_CLOSE, None, None)
            log.info("Closed Office window.")
    return True
Ejemplo n.º 2
0
def get_office_window(hwnd, lparam):
    global CLOSED_OFFICE
    if USER32.IsWindowVisible(hwnd):
        text = create_unicode_buffer(1024)
        USER32.GetWindowTextW(hwnd, text, 1024)
        if "- Microsoft" in text.value or "- Word" in text.value or "- Excel" in text.value or "- PowerPoint" in text.value:
            # send ALT+F4 equivalent
            log.info("Closing Office window.")
            USER32.SendNotifyMessageW(hwnd, WM_CLOSE, None, None)
            CLOSED_OFFICE = True
    return True
Ejemplo n.º 3
0
def get_office_window(hwnd, lparam):
    '''
    Callback procedure invoked for every enumerated window.
    Purpose is to close any office window.
    '''
    if USER32.IsWindowVisible(hwnd):
        text = get_window_text(hwnd)
        if re.search("(Microsoft|Word|Excel|PowerPoint)", text):
            USER32.SendNotifyMessageW(hwnd, WM_CLOSE, None, None)
            KERNEL32.Sleep(1000)
            log.info("Closed Office window: %s", text)
    return True