-
Notifications
You must be signed in to change notification settings - Fork 510
Window focus during debug in VSCode #1175
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
Thanks for the report @ryanfog! @rkeithhill this has happened with other windows, right? Like the credential window I think... or the Azure login window. |
Yup. In this case, the issue is specific to Windows since Windows Forms doesn't run on Linux/macOS. At first I thought you could solve this by getting VSCODE's main window handle: $handle = (Get-Process -ID $env:VSCODE_ID).MainWindowHandle and wrapping that in a type that implement IWin32Window e.g.: $owner = [System.Windows.Forms.NativeWindow]::FromHandle($handle) and then pass that owner into the |
@rkeithhill it looks like this also happens in the default PowerShell console that VSCode provides. Perhaps we should open a bug on them (if one's not already opened) and see if they have any ideas? |
Perhaps we open an enhancement request on VSCode i.e. provide a way that an extension OR a debugged end-user program can bring UI to the top, over VSCode. Often UI generated by other programs (debug extension, user programs) show up behind VSCode and it confuses users (causes bug submissions). BTW there may be other ways to do this for certain types of UI where you can get the Window handle and use the SetForegroundWindow() Win32 API to bring that window to the top. This unfortunately doesn't work so well with modal UI like ShowDialog() (unless you want to spin up a job to do this). |
•VSCode Version: Code 1.19.3 (7c4205b, 2018-01-25T10:36:34.867Z)
•OS Version: Windows_NT x64 10.0.16299
•Extensions:
Author (truncated)
Version
PowerShell ms- 1.5.1
team ms- 1.122.0
Issue Description
I use the code snippet below a lot to display a windows explorer window for the selection of a input file by a end user. When debugging in VSCode the dialog box that is called is not brought to the foreground. In order to see the dialog, you need to minimize VSCode answer the dialog which returns focus back to VSCode.
Function Get-FileName($StartDirectory){
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
$openFileDialog = New-Object System.Windows.Forms.OpenFileDialog
$openFileDialog.initialDirectory = $StartDirectory
$openFileDialog.filter = "All files (.)| ."
$openFileDialog.ShowDialog() | Out-Null
$openFileDialog.filename
}
Attached Logs
PSR of issue.zip
The text was updated successfully, but these errors were encountered: