This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients eryksun, iMath, mmaswg, ohno, paul.moore, steve.dower, tim.golden, zach.ware
Date 2021-10-30.08:04:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1635581073.37.0.192079114926.issue30082@roundup.psfhosted.org>
In-reply-to
Content
Here's an example test that calls WinAPI GetConsoleWindow() and IsWindowVisble() in a child process.

    if mswindows:
        try:
            import ctypes
        except ImportError:
            ctypes = None

    # added in Win32ProcessTestCase
    def test_force_hide(self):
        if ctypes:
            script = textwrap.dedent(r'''
                import sys, ctypes
                GetConsoleWindow = ctypes.WinDLL('kernel32').GetConsoleWindow
                IsWindowVisible = ctypes.WinDLL('user32').IsWindowVisible
                sys.exit(IsWindowVisible(GetConsoleWindow()))
            ''')
        else:
            script = 'import sys; sys.exit(0)'
        rc = subprocess.call([sys.executable, '-c', script], force_hide=True)
        self.assertEqual(rc, 0)

This test will work reliably even if the user has Windows Terminal set as the default terminal (available with recent builds of Windows and Windows Terminal Preview). The proxy does not hand off to Windows Terminal if the STARTUPINFO wShowWindow is SW_HIDE or SW_SHOWMINIMIZED, or if the process is created with the CREATE_NO_WINDOW flag. In these cases, it just creates a system conhost.exe session.
History
Date User Action Args
2021-10-30 08:04:33eryksunsetrecipients: + eryksun, paul.moore, tim.golden, zach.ware, steve.dower, iMath, ohno, mmaswg
2021-10-30 08:04:33eryksunsetmessageid: <1635581073.37.0.192079114926.issue30082@roundup.psfhosted.org>
2021-10-30 08:04:33eryksunlinkissue30082 messages
2021-10-30 08:04:33eryksuncreate