Eryk Sun <[email protected]> added the comment:
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.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue30082>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com