Message405362
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. |
|
Date |
User |
Action |
Args |
2021-10-30 08:04:33 | eryksun | set | recipients:
+ eryksun, paul.moore, tim.golden, zach.ware, steve.dower, iMath, ohno, mmaswg |
2021-10-30 08:04:33 | eryksun | set | messageid: <1635581073.37.0.192079114926.issue30082@roundup.psfhosted.org> |
2021-10-30 08:04:33 | eryksun | link | issue30082 messages |
2021-10-30 08:04:33 | eryksun | create | |
|