def is_separate_console_window():
    """    Check if the process owns a console window.

    Return True if the console window was opened with this process.
    Return False if the console was already open and this application was
    started within it.
    """
    import ctypes
    import ctypes.wintypes
    window = ctypes.windll.kernel32.GetConsoleWindow()
    console_pid = ctypes.wintypes.DWORD()
    ctypes.windll.user32.GetWindowThreadProcessId(window, ctypes.byref(
        console_pid))
    return console_pid.value == ctypes.windll.kernel32.GetCurrentProcessId()
