pywinpty
pywinpty copied to clipboard
First call of `PtyProcess.spawn` creates a visible terminal window stealing focus of invocating app.
If PtyProcess.spawn() is called from a GUI app, it creates a visible forground terminal window, which is then closed or hidden right after.
Thus the calling application looses focus.
On Windows OS CLI proceess need to be started with special startupinfo structure to ensure they are started in a hidden unfocused background window to avoid that effect.
Related python code to start such process is:
startupinfo = None
if WIN32:
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.SW_HIDE | subprocess.STARTF_USESHOWWINDOW
proc = subprocess.Popen(
args=args,
startupinfo=startupinfo,
)
It seems related Rust code does not properly set those window attributes when starting a CLI process.
originally reported at https://github.com/sublimehq/sublime_text/issues/6550
btw: Please provide a fix as python 3.8 wheel so Sublime Text can make use of it.