-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Start-Process -WindowStyle Minimized steals focus #7790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is basically the same issue as #3028 and the solution is the same: create a windows host for PowerShell as opposed to the existing console host. |
This issue and #3028 are distinct use cases:
Therefore, this issue calls for a different solution, namely an enhancement to the |
Thus - unless you see a flaw in my clarification - please remove the |
@mklement0 You didn't mention |
Thanks, @BrucePay: Yes, arguably To future readers / potential implementers in PowerShell: It is the Examples of using the VisualBasic assembly you mention (Windows only): Add-Type -Assembly Microsoft.VisualBasic
# Launch a GUI application in a minimized window without focus:
[Microsoft.VisualBasic.Interaction]::Shell('Notepad', 'MinimizedNoFocus')
# Launch a console application in a minimized window without focus
# !! Specifying a console application *directly* doesn't work, because it would run in the
# !! *current* console window.
# !! The *conhost.exe workaround* requires *Windows 10*
[Microsoft.VisualBasic.Interaction]::Shell('conhost cmd /k echo hi', 'MinimizedNoFocus') |
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you. |
2 similar comments
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you. |
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you. |
This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes. |
It's fair to assume that you typically do not want the newly created, minimized window to steal focus from the calling application when you use
Start-Process -WindowStyle Minimized
.That is, the calling application (console window) should remain the active application and continue to receive keyboard output.
Currently,
-WindowStyle Minimized
invariably focuses the minimized window - while the calling window is by definition not obscured, it loses keyboard focus that way.Two possible enhancements:
Change
-WindowStyle Minimized
to not steal focus.Since that is technically a breaking change - someone may rely on the old behavior, though I have trouble picturing why - alternatively introduce a new style,
MinimizedNoFocus
similar to Visual Basic's[AppWinStyle]
enumeration.NormalNoFocus
could be implemented too (that is, start a process with normal window size, but without giving it focus).Update:
A related, but distinct issue is #3028, which concern's the CLI's (the
pwsh
executable's)-WindowStyle
parameter, notably the ability to start PowerShell as a whole hidden.Environment data
Written as of:
The text was updated successfully, but these errors were encountered: