Sometimes the Terminal launches behind all other windows / without foreground / isn't activated #20010

Closed
opened 2026-01-31 07:00:25 +00:00 by claunia · 49 comments
Owner

Originally created by @marbaa on GitHub (May 30, 2023).

Windows Terminal version

1.18.1421.0

Windows build number

10.0.22621.1702

Other Software

No response

Steps to reproduce

Just leave the default value in Settings -> Launch parameters -> Launch Mode -> Default.

Terminal window is launched but has no focus. Doesn't matter which profile is set to default, if Powershell, or WSL, or whatever else. Often happens that if I'm in other application and I run Terminal, from pinned taskbar icon for example, it is not visible at all. Doesn't matter if I run it with keyboard shortcut Win + 1-9 or with middle mouse button. It starts behind the current application which I'm in.

Expected Behavior

Terminal window in foreground with focus.

Actual Behavior

Terminal window in foreground without focus, and sometimes even hidden behind other application.

Originally created by @marbaa on GitHub (May 30, 2023). ### Windows Terminal version 1.18.1421.0 ### Windows build number 10.0.22621.1702 ### Other Software _No response_ ### Steps to reproduce Just leave the default value in Settings -> Launch parameters -> Launch Mode -> Default. Terminal window is launched but has no focus. Doesn't matter which profile is set to default, if Powershell, or WSL, or whatever else. Often happens that if I'm in other application and I run Terminal, from pinned taskbar icon for example, it is not visible at all. Doesn't matter if I run it with keyboard shortcut Win + 1-9 or with middle mouse button. It starts behind the current application which I'm in. ### Expected Behavior Terminal window in foreground with focus. ### Actual Behavior Terminal window in foreground without focus, and sometimes even hidden behind other application.
Author
Owner

@carlos-zamora commented on GitHub (May 31, 2023):

@DHowett had a pretty simple repro with:
wt -w -1
Run that from the Run dialog

@carlos-zamora commented on GitHub (May 31, 2023): @DHowett had a pretty simple repro with: `wt -w -1` Run that from the Run dialog
Author
Owner

@marbaa commented on GitHub (Jun 19, 2023):

Found situation when this nofocus issue occurs. It is because of Quake mode.

Steps to repro:
1. Lanuch WT by whatever way it is possible (from Start menu, from taskbar, .exe, ...)
2. Open Quake-mode with WIN + ~~ ~~3. Launch some ssh session there (I have always running ```az network tunnel``` session in Quake-mode window)~~ ~~4. Hide Quake-mode with WIN +
5. Launch new WT instance from step 1.

This way, new lanuched WT doesn't have focus. If you disconnect the sessions in Quake-mode, and hide Quake-mode, then the newly WT instances will have focus correctly.

edit 20.6.
Above is not true. Next day, it happened without using Quake-mode.

@marbaa commented on GitHub (Jun 19, 2023): ~~Found situation when this nofocus issue occurs. It is because of Quake mode.~~ ~~Steps to repro:~~ ~~1. Lanuch WT by whatever way it is possible (from Start menu, from taskbar, .exe, ...)~~ ~~2. Open Quake-mode with WIN + `~~ ~~3. Launch some ssh session there (I have always running ```az network tunnel``` session in Quake-mode window)~~ ~~4. Hide Quake-mode with WIN + `~~ ~~5. Launch new WT instance from step 1.~~ ~~This way, new lanuched WT doesn't have focus. If you disconnect the sessions in Quake-mode, and hide Quake-mode, then the newly WT instances will have focus correctly.~~ edit 20.6. Above is not true. Next day, it happened without using Quake-mode.
Author
Owner

@zadjii-msft commented on GitHub (Sep 20, 2023):

Uhg guys I can't get this to repro. Certainly not consistently. I had it happen like, once by

  • shift clicking on the taskbar (with a window already open),
  • waiting what seemed like a minute
  • activating other windows. Minimizing one.
  • then eventually the new window appeared, beneath everything.

I reckon that this regressed in the #5000 changes. Especially somewhere around the way that a new window gets summoned in the existing process.

I just can't for the life of me get a consistent repro. It probably depends on

  • If there's a terminal window already running
  • How you spawn the new terminal window
  • what you do before the new terminal window launches
@zadjii-msft commented on GitHub (Sep 20, 2023): Uhg guys I can't get this to repro. Certainly not consistently. I had it happen like, _once_ by * shift clicking on the taskbar (with a window already open), * waiting what seemed like a minute * activating other windows. Minimizing one. * then _eventually_ the new window appeared, beneath everything. I reckon that this regressed in the #5000 changes. Especially somewhere around the way that a new window gets summoned in the existing process. I just can't for the life of me get a consistent repro. It probably depends on * If there's a terminal window already running * How you spawn the new terminal window * what you do before the new terminal window launches
Author
Owner

@zadjii-msft commented on GitHub (Sep 20, 2023):

Something blind we could try:

diff --git a/src/cascadia/WindowsTerminal/AppHost.cpp b/src/cascadia/WindowsTerminal/AppHost.cpp
index 81218dbf4..af5d8d7ff 100644
--- a/src/cascadia/WindowsTerminal/AppHost.cpp
+++ b/src/cascadia/WindowsTerminal/AppHost.cpp
@@ -1406,6 +1406,8 @@ winrt::fire_and_forget AppHost::_WindowInitializedHandler(const winrt::Windows::
                               nCmdShow == SW_FORCEMINIMIZE;
     if (!noForeground)
     {
+        LOG_IF_WIN32_BOOL_FALSE(BringWindowToTop(_window->GetHandle()));
+
         SetForegroundWindow(_window->GetHandle());
         _peasantNotifyActivateWindow();
     }

around: 059f7701f2/src/cascadia/WindowsTerminal/AppHost.cpp (L1396-L1412)

That's what I'd bet the culprit is, if there is one.

@zadjii-msft commented on GitHub (Sep 20, 2023): Something blind we could try: ```diff diff --git a/src/cascadia/WindowsTerminal/AppHost.cpp b/src/cascadia/WindowsTerminal/AppHost.cpp index 81218dbf4..af5d8d7ff 100644 --- a/src/cascadia/WindowsTerminal/AppHost.cpp +++ b/src/cascadia/WindowsTerminal/AppHost.cpp @@ -1406,6 +1406,8 @@ winrt::fire_and_forget AppHost::_WindowInitializedHandler(const winrt::Windows:: nCmdShow == SW_FORCEMINIMIZE; if (!noForeground) { + LOG_IF_WIN32_BOOL_FALSE(BringWindowToTop(_window->GetHandle())); + SetForegroundWindow(_window->GetHandle()); _peasantNotifyActivateWindow(); } ``` around: https://github.com/microsoft/terminal/blob/059f7701f241a314a049eb5d2c62cf7f4c3b803f/src/cascadia/WindowsTerminal/AppHost.cpp#L1396-L1412 That's what I'd bet the culprit is, if there is one.
Author
Owner

@w3lld0ne commented on GitHub (Sep 20, 2023):

Uhg guys I can't get this to repro. Certainly not consistently. I had it happen like, once by

  • shift clicking on the taskbar (with a window already open),
  • waiting what seemed like a minute
  • activating other windows. Minimizing one.
  • then eventually the new window appeared, beneath everything.

I reckon that this regressed in the #5000 changes. Especially somewhere around the way that a new window gets summoned in the existing process.

I just can't for the life of me get a consistent repro. It probably depends on

  • If there's a terminal window already running
  • How you spawn the new terminal window
  • what you do before the new terminal window launches

Not sure it's actually related to this issue but anyways, regarding a non-focused window on startup, you can also take a look at this thread from Directory Opus user.

I can confirm the same behaviour: invoking default "Open in Terminal" context menu entry in DOpus is misbehaving (it's not happening with Explorer or when launching the Terminal from Start Menu, though).

@w3lld0ne commented on GitHub (Sep 20, 2023): > Uhg guys I can't get this to repro. Certainly not consistently. I had it happen like, _once_ by > > * shift clicking on the taskbar (with a window already open), > * waiting what seemed like a minute > * activating other windows. Minimizing one. > * then _eventually_ the new window appeared, beneath everything. > > I reckon that this regressed in the #5000 changes. Especially somewhere around the way that a new window gets summoned in the existing process. > > I just can't for the life of me get a consistent repro. It probably depends on > > * If there's a terminal window already running > * How you spawn the new terminal window > * what you do before the new terminal window launches Not sure it's actually related to this issue but anyways, regarding a non-focused window on startup, you can also take a look at [this thread](https://resource.dopus.com/t/windows-terminal-appears-behind-dopus-window-when-launched-from-context-menu/44593) from Directory Opus user. I can confirm the same behaviour: invoking default "Open in Terminal" context menu entry in DOpus is misbehaving (it's not happening with Explorer or when launching the Terminal from Start Menu, though).
Author
Owner

@zadjii-msft commented on GitHub (Sep 20, 2023):

Welp. I can't repro that with Directory Opus myself. Just launches straight to the foreground, from both a cold launch and a warm launch.

Are you doing anything weird with elevate: true in your profiles? From the GIF in the linked thread, that looks like they're running with UAC disabled entirely, but that might be another variable here.

@zadjii-msft commented on GitHub (Sep 20, 2023): Welp. I can't repro that with Directory Opus myself. Just launches straight to the foreground, from both a cold launch and a warm launch. Are you doing anything weird with `elevate: true` in your profiles? From the GIF in the linked thread, that looks like they're running with UAC disabled entirely, but that might be another variable here.
Author
Owner

@w3lld0ne commented on GitHub (Sep 21, 2023):

Welp. I can't repro that with Directory Opus myself. Just launches straight to the foreground, from both a cold launch and a warm launch.

Are you doing anything weird with elevate: true in your profiles? From the GIF in the linked thread, that looks like they're running with UAC disabled entirely, but that might be another variable here.

Indeed, I had UAC disabled as well, but after re-enabling it, Terminal no longer launches as admin, but still launches behind DOpus window. Also note that the problem is only with 'Open in Terminal' entry, if for example I launch PowerShell or Cmd directly - everything works fine, they're opened in Terminal which is correctly brought to foreground.

Update1: It happens for me regardless of LaunchMode mentioned in this issue (I've tried 'Default', 'Maximized', 'Fullscreen', 'Focus', 'Maximized Focus' and they all appear behind DOpus).

Update2: If I now set the default profile to launch elevated, the system correctly shows me UAC prompt and then brings the window to foreground.

Update3: If I launch DOpus itself elevated, then there is no 'Open in Terminal' entry anymore and when I try to launch PowerShell/Cmd directly they no longer spawn inside WT, but instead in their own consoles.

@w3lld0ne commented on GitHub (Sep 21, 2023): > Welp. I can't repro that with Directory Opus myself. Just launches straight to the foreground, from both a cold launch and a warm launch. > > Are you doing anything weird with `elevate: true` in your profiles? From the GIF in the linked thread, that looks like they're running with UAC disabled entirely, but that might be another variable here. Indeed, I had UAC disabled as well, but after re-enabling it, Terminal no longer launches as admin, but still launches behind DOpus window. Also note that the problem is only with 'Open in Terminal' entry, if for example I launch PowerShell or Cmd directly - everything works fine, they're opened in Terminal which is correctly brought to foreground. Update1: It happens for me regardless of LaunchMode mentioned in this issue (I've tried 'Default', 'Maximized', 'Fullscreen', 'Focus', 'Maximized Focus' and they all appear behind DOpus). Update2: If I now set the default profile to launch elevated, the system correctly shows me UAC prompt and then brings the window to foreground. Update3: If I launch DOpus itself elevated, then there is no 'Open in Terminal' entry anymore and when I try to launch PowerShell/Cmd directly they no longer spawn inside WT, but instead in their own consoles.
Author
Owner

@marbaa commented on GitHub (Sep 25, 2023):

I can repro my previous steps like 99% all the time. Doesn't matter if it is fresh boot with nothing running, or launching over 30 apps.

Next thing is if I click drop arrow in terminal, and Shift + Click on any profile, new window is shown behind Terminal window from which I executed new profile, not in foreground. But now, not always, steps to reproduce:

  1. Don't have any Terminal running.
  2. Start Terminal with whatever way.
  3. Shift + Click on any new profile in down arrow menu - new Terminal window is shown in background.
  4. Shift + Click again on any new profile to open another session - new Terminal winndow is now shown in foreground.

But this is not 100% always. If I do it continuously, it spawns new windows randomly in foreground/background.

@marbaa commented on GitHub (Sep 25, 2023): I can repro my previous steps like 99% all the time. Doesn't matter if it is fresh boot with nothing running, or launching over 30 apps. Next thing is if I click drop arrow in terminal, and Shift + Click on any profile, new window is shown behind Terminal window from which I executed new profile, not in foreground. But now, not always, steps to reproduce: 1. Don't have any Terminal running. 2. Start Terminal with whatever way. 3. Shift + Click on any new profile in down arrow menu - new Terminal window is shown in background. 4. Shift + Click again on any new profile to open another session - new Terminal winndow is now shown in foreground. But this is not 100% always. If I do it continuously, it spawns new windows randomly in foreground/background.
Author
Owner

@lhecker commented on GitHub (Sep 26, 2023):

Relatedly to this issue, WT sometimes opens in the background, behind all other applications. I can fairly readily reproduce that by holding shift while clicking it in the start menu. Holding shift should simply make the launched application unfocused and this works correctly for e.g. conhost, but WT doesn't even launch in the foreground.

@lhecker commented on GitHub (Sep 26, 2023): Relatedly to this issue, WT sometimes opens in the background, behind all other applications. I can fairly readily reproduce that by holding shift while clicking it in the start menu. Holding shift should simply make the launched application unfocused and this works correctly for e.g. conhost, but WT doesn't even launch in the foreground.
Author
Owner

@marbaa commented on GitHub (Sep 27, 2023):

Now, with v1.19, WT is launched in background 100% times, behind all apps. Looks like new instance is put on the last place of Z-order.
If no apps are running, WT is launched with no focus.

@marbaa commented on GitHub (Sep 27, 2023): Now, with v1.19, WT is launched in background 100% times, behind all apps. Looks like new instance is put on the last place of Z-order. If no apps are running, WT is launched with no focus.
Author
Owner

@zadjii-msft commented on GitHub (Sep 27, 2023):

I can fairly readily reproduce that by holding shift while clicking it in the start menu.

You wanna know something crazy? I can 100% repro that, UNLESS I have a debugger attached. With either VS or WinDBG attached, the window always opens in the front, with foreground. That's just amazingly annoying for the sake of attempting to debug.

Interestingly enough, I get the same behavior with Notepad that I'm seeing here. Curious.

@zadjii-msft commented on GitHub (Sep 27, 2023): > I can fairly readily reproduce that by holding shift while clicking it in the start menu. You wanna know something crazy? I can 100% repro that, UNLESS I have a debugger attached. With either VS or WinDBG attached, the window always opens in the front, with foreground. That's just amazingly annoying for the sake of attempting to debug. Interestingly enough, I get the same behavior with Notepad that I'm seeing here. Curious.
Author
Owner

@w3lld0ne commented on GitHub (Oct 3, 2023):

Interestingly enough, I get the same behavior with Notepad that I'm seeing here. Curious.

For me, it sometimes also happens with ShareX, when double-clicking their tray icon. May be not a Terminal, but a Windows issue?

Also, found out that the second & further Terminal windows always open behind any other apps & even behind previous Terminal windows. This happens regardless of how the first window was launched.
NVIDIA_Share_VnhH32fR9W

This is the latest v1.18, and the following param: image

@w3lld0ne commented on GitHub (Oct 3, 2023): > Interestingly enough, I get the same behavior with Notepad that I'm seeing here. Curious. For me, it sometimes also happens with ShareX, when double-clicking their tray icon. May be not a Terminal, but a Windows issue? Also, found out that the second & further Terminal windows always open behind any other apps & even behind previous Terminal windows. This happens regardless of how the first window was launched. ![NVIDIA_Share_VnhH32fR9W](https://github.com/microsoft/terminal/assets/14851973/9a29b56f-8125-472c-970e-b862924eb858) This is the latest v1.18, and the following param: ![image](https://github.com/microsoft/terminal/assets/14851973/bde60709-ed2b-47d4-9f29-082f71259509)
Author
Owner

@MolotovCherry commented on GitHub (Oct 28, 2023):

This seems to happen to me when I enable open a quake window / run in headless

It stops happening once I kill all wt processes and there's no quake mode enabled

For me, 100% reproducibility

@MolotovCherry commented on GitHub (Oct 28, 2023): This seems to happen to me when I enable open a quake window / run in headless It stops happening once I kill all wt processes and there's no quake mode enabled For me, 100% reproducibility
Author
Owner

@wreiske commented on GitHub (Nov 9, 2023):

This is incredibly annoying on windows 11 since there is no way to ungroup taskbar items (or at least there wasn't, I haven't researched lately)... I feel like recently something has changed with how this works.

I'll hit windows key, type term and hit enter to open a new terminal fast. It's in my muscle memory. Now I have to go searching for the new window every time!

@wreiske commented on GitHub (Nov 9, 2023): This is incredibly annoying on windows 11 since there is no way to ungroup taskbar items (or at least there wasn't, I haven't researched lately)... I feel like recently something has changed with how this works. I'll hit windows key, type term and hit enter to open a new terminal fast. It's in my muscle memory. Now I have to go searching for the new window every time!
Author
Owner

@M322458 commented on GitHub (Nov 14, 2023):

I have the same issue. Just started after a fresh install of windows and all apps.

@M322458 commented on GitHub (Nov 14, 2023): I have the same issue. Just started after a fresh install of windows and all apps.
Author
Owner

@M322458 commented on GitHub (Nov 14, 2023):

I went to settings, changed the launch parameters and tested a few options and saved. Changed them back to defaults and now it's not happening. We'll see if it re-occurs.

@M322458 commented on GitHub (Nov 14, 2023): I went to settings, changed the launch parameters and tested a few options and saved. Changed them back to defaults and now it's not happening. We'll see if it re-occurs.
Author
Owner

@M322458 commented on GitHub (Nov 15, 2023):

I went to settings, changed the launch parameters and tested a few options and saved. Changed them back to defaults and now it's not happening. We'll see if it re-occurs.

It didn't fix it for long.

@M322458 commented on GitHub (Nov 15, 2023): > I went to settings, changed the launch parameters and tested a few options and saved. Changed them back to defaults and now it's not happening. We'll see if it re-occurs. It didn't fix it for long.
Author
Owner

@lucasreddinger commented on GitHub (Nov 15, 2023):

I can confirm the same behaviour: invoking default "Open in Terminal" context menu entry in DOpus is misbehaving (it's not happening with Explorer or when launching the Terminal from Start Menu, though).

"Open in Terminal" in Explorer does it for me sometimes. I'll try to figure out how to reproduce it reliably.

Infuriating!

@lucasreddinger commented on GitHub (Nov 15, 2023): > I can confirm the same behaviour: invoking default "Open in Terminal" context menu entry in DOpus is misbehaving (it's not happening with Explorer or when launching the Terminal from Start Menu, though). "Open in Terminal" in Explorer does it for me _sometimes_. I'll try to figure out how to reproduce it reliably. Infuriating!
Author
Owner

@Hicsy commented on GitHub (Jan 16, 2024):

2 days ago i noticed that when using the windows 11 context-menu Open in Terminal: Terminal launches BEHIND explorer 100% of the time.
I use that link ~300 times per day and didn't notice it before, but I have an ultrawide, so perhaps it was always like this and I just fluked explorer never being in the same spot when it launches. More realistic estimate might be ~2-3 months ago when Power Rename also started opening behind W11 Explorer 100% of time when using that same context menu.
I now end up with literally dozens of terminal windows in the background when I go to shutdown my PC each day, reminding me of all the times I didn't notice it launching behind focus.

@Hicsy commented on GitHub (Jan 16, 2024): 2 days ago i noticed that when using the windows 11 context-menu `Open in Terminal`: Terminal launches BEHIND explorer 100% of the time. I use that link ~300 times per day and didn't notice it before, _but I have an ultrawide, so perhaps it was always like this and I just fluked explorer never being in the same spot when it launches_. More realistic estimate might be ~2-3 months ago when Power Rename also started opening behind W11 Explorer 100% of time when using that same context menu. I now end up with literally dozens of terminal windows in the background when I go to shutdown my PC each day, reminding me of all the times I didn't notice it launching behind focus.
Author
Owner

@AshleyScirra commented on GitHub (Jan 17, 2024):

In case it helps, I can reproduce this 100% on Windows 11 with these steps:

  1. Open File Explorer to a folder
  2. Right-click in a space in the folder and choose 'Open in Terminal' - it appears on top
  3. Minimize that Terminal window
  4. Right-click in a space in the folder and choose 'Open in Terminal' again - it appears underneath

I can't recall exactly but I don't think 'Open in Terminal' is in the explorer context menu by default, I think there's some developer setting to turn that on. Also step 4 requires that the terminal window attempts to open in a position overlapping File Explorer, so you might need to drag windows around to make sure that at step 4 they overlap.

This is really annoying for me as for my job I start the day by opening Terminal, starting a HTTP server, minimizing it, then doing web development all day which occasionally involves opening more terminals, which always appear under File Explorer every time.

@AshleyScirra commented on GitHub (Jan 17, 2024): In case it helps, I can reproduce this 100% on Windows 11 with these steps: 1. Open File Explorer to a folder 2. Right-click in a space in the folder and choose 'Open in Terminal' - it appears on top 3. Minimize that Terminal window 4. Right-click in a space in the folder and choose 'Open in Terminal' again - it appears underneath I can't recall exactly but I don't think 'Open in Terminal' is in the explorer context menu by default, I think there's some developer setting to turn that on. Also step 4 requires that the terminal window attempts to open in a position overlapping File Explorer, so you might need to drag windows around to make sure that at step 4 they overlap. This is really annoying for me as for my job I start the day by opening Terminal, starting a HTTP server, minimizing it, then doing web development all day which occasionally involves opening more terminals, which always appear under File Explorer every time.
Author
Owner

@pTinosq commented on GitHub (Feb 28, 2024):

I am having the exact same issues. Interestingly enough here's what I have found:

  1. Running wt in the run window = window goes to back
  2. Searching in windows search for "terminal" then pressing enter = window goes to back
  3. Right clicking taskbar icon and selecting terminal = window goes to back
  4. Opening terminal by doing win + x then selecting terminal = windows goes to front????

So a temporary shortcut for fellow shortcut lovers is to do win + x then i. That's the fastest way I have found to open a new wt without it going to the back.

This is so frustrating 🥲

@pTinosq commented on GitHub (Feb 28, 2024): I am having the exact same issues. Interestingly enough here's what I have found: 1. Running `wt` in the run window = window goes to back 2. Searching in windows search for "terminal" then pressing enter = window goes to back 3. Right clicking taskbar icon and selecting terminal = window goes to back 4. Opening terminal by doing <kbd>win + x</kbd> then selecting terminal = windows goes to front???? So a temporary shortcut for fellow shortcut lovers is to do <kbd>win + x</kbd> then <kbd>i</kbd>. That's the fastest way I have found to open a new wt without it going to the back. This is so frustrating 🥲
Author
Owner

@MolotovCherry commented on GitHub (Feb 28, 2024):

To follow up on pTinosq, I've been having this problem of it launching in the background for a long time.

I can confirm point 4 indeed did cause it to go to front for me. Huh.

@MolotovCherry commented on GitHub (Feb 28, 2024): To follow up on pTinosq, I've been having this problem of it launching in the background for a long time. I can confirm point 4 indeed did cause it to go to front for me. Huh.
Author
Owner

@jakenybo commented on GitHub (Feb 28, 2024):

in my configuration, right-clicking inside a folder in windows explorer and selecting "Open in Terminal" launches the Windows Terminal window behind the Windows Explorer window. frustrating because it require me to click down on the taskbar to bring it to the front for use. any suggestions on a fix?

@jakenybo commented on GitHub (Feb 28, 2024): in my configuration, right-clicking inside a folder in windows explorer and selecting "Open in Terminal" launches the Windows Terminal window behind the Windows Explorer window. frustrating because it require me to click down on the taskbar to bring it to the front for use. any suggestions on a fix?
Author
Owner

@lucasreddinger commented on GitHub (Feb 28, 2024):

@AshleyScirra thank you for your replication steps. they also replicate for me.

--

@jakenybo do the steps provided in https://github.com/microsoft/terminal/issues/15479#issuecomment-1895644698 replicate your issue reliably (and compared to beginning with no terminal windows open and minimized)?

many people here report being frustrated with this problem, so i would assume these people do not have a fix. i suspect we simply have to use workarounds

@lucasreddinger commented on GitHub (Feb 28, 2024): @AshleyScirra thank you for your replication steps. they also replicate for me. -- @jakenybo do the steps provided in https://github.com/microsoft/terminal/issues/15479#issuecomment-1895644698 replicate your issue reliably (and compared to beginning with no terminal windows open and minimized)? many people here report being frustrated with this problem, so i would assume these people do not have a fix. i suspect we simply have to use workarounds
Author
Owner

@jakenybo commented on GitHub (Feb 28, 2024):

@lucasreddinger, yes those steps replicate the same behavior on my machine. i'm learning that i think the issue has more to do with whether or not you already have an instance of Windows Terminal running. if no prior Windows Terminal instance is running, the "Open in Terminal" option in a folder will open the Windows Terminal window on top of Windows Explorer (as it should). if you already have another instance of Windows Terminal running (even minimized to system tray, as is the case with me), then all subsequent "Open in Terminal" options will open the Windows Terminal window behind the WIndows Explorer window (which is erroneous behavior given its default behavior). i don't know why anyone would ever want it to open in the background if you just selected "Open in Terminal". that should always result in Window Terminal opening on top of all other windows

a fix for this would be great!

@jakenybo commented on GitHub (Feb 28, 2024): @lucasreddinger, yes those steps replicate the same behavior on my machine. i'm learning that i think the issue has more to do with whether or not you already have an instance of Windows Terminal running. if no prior Windows Terminal instance is running, the "Open in Terminal" option in a folder will open the Windows Terminal window on top of Windows Explorer (as it should). if you already have another instance of Windows Terminal running (even minimized to system tray, as is the case with me), then all subsequent "Open in Terminal" options will open the Windows Terminal window behind the WIndows Explorer window (which is erroneous behavior given its default behavior). i don't know why anyone would ever want it to open in the background if you just selected "Open in Terminal". that should always result in Window Terminal opening on top of all other windows a fix for this would be great!
Author
Owner

@barthofu commented on GitHub (Mar 5, 2024):

Also having the problem here!

I came to the same conclusion as @jakenybo.

Versions

  • Windows Terminal: 1.19.10573.0
  • Windows version: Windows 11 Family - 23H2 - 22631.3155
@barthofu commented on GitHub (Mar 5, 2024): Also having the problem here! I came to the same conclusion as @jakenybo. ### Versions - Windows Terminal: `1.19.10573.0` - Windows version: `Windows 11 Family - 23H2 - 22631.3155`
Author
Owner

@alex-campulungeanu commented on GitHub (Mar 10, 2024):

in my case, the win+r + wt combination openes a terminal in foreground if i have another terminal opened which was moved on the screen using winkey+alt

@alex-campulungeanu commented on GitHub (Mar 10, 2024): in my case, the win+r + wt combination openes a terminal in foreground if i have another terminal opened which was moved on the screen using winkey+alt
Author
Owner

@eonward commented on GitHub (Mar 21, 2024):

I experience this behavior consistently when:

  • Launching from from system-generated start menu shortcut, search result, or 'all apps' list
    • Except when launching in admin mode
  • Launching from pinned taskbar element (or by left clicking taskbar element > l-click Terminal > Open)
    • Except when launching in admin mode

This behavior does not occur when:

  • Launching from Win + X menu
  • Launching by double clicking executable
  • Launching from user-created shortcut

In my case, the behavior described above is consistent across profiles, launching directories, and seems independent of running instances and in-app settings.

Build 22631.3296
WT 1.19.10573.0

PD: Here's the icon in case anyone is trying to make new shortcuts:
https://raw.githubusercontent.com/microsoft/terminal/master/res/terminal.ico

@eonward commented on GitHub (Mar 21, 2024): I experience this behavior consistently when: - Launching from from system-generated start menu shortcut, search result, or 'all apps' list - Except when launching in admin mode - Launching from pinned taskbar element (or by left clicking taskbar element > l-click Terminal > Open) - Except when launching in admin mode This behavior does not occur when: - Launching from Win + X menu - Launching by double clicking executable - Launching from user-created shortcut In my case, the behavior described above is consistent across profiles, launching directories, and seems independent of running instances and in-app settings. Build 22631.3296 WT 1.19.10573.0 PD: Here's the icon in case anyone is trying to make new shortcuts: https://raw.githubusercontent.com/microsoft/terminal/master/res/terminal.ico
Author
Owner

@marbaa commented on GitHub (Mar 22, 2024):

New observation. I'm getting 100% no-focus when launching Terminal with WSL2 default profile for the first time. Doesn't matter how/from where.

As for fist time it took like 2-3 seconds to start WSL2. Probably it is launhch Hyper-V services or whatever else, I don't know. During startup it has focus, WSL2 distro shows shell and Terminal loses focus. Funny thing is that while it is starting, it affect VMware Player window, because it flashes.

Often ctrl + click from dropdown menu opens new Terminal without focus, or even behind current Terminal window.
Mess..

Terminal Version: 1.20.10572.0
Windows 11 22H2 (22621.3155)
Dell 7560 + NVIDIA T1200 (driver 551.61)

I think it never happened with WSL1 as it starts instantly.

@marbaa commented on GitHub (Mar 22, 2024): New observation. I'm getting 100% no-focus when launching Terminal with WSL2 default profile for the first time. Doesn't matter how/from where. As for fist time it took like 2-3 seconds to start WSL2. Probably it is launhch Hyper-V services or whatever else, I don't know. During startup it has focus, WSL2 distro shows shell and Terminal loses focus. Funny thing is that while it is starting, it affect VMware Player window, because it flashes. Often ctrl + click from dropdown menu opens new Terminal without focus, or even behind current Terminal window. Mess.. Terminal Version: 1.20.10572.0 Windows 11 22H2 (22621.3155) Dell 7560 + NVIDIA T1200 (driver 551.61) I think it never happened with WSL1 as it starts instantly.
Author
Owner

@tusharsnx commented on GitHub (Mar 22, 2024):

@marbaa That sounds like the WSL issue here: https://github.com/microsoft/wslg/issues/1212.

This also means that specific issue is not related to WT, and could be repro on other terminals (Eg. VS, VSCode)

@tusharsnx commented on GitHub (Mar 22, 2024): @marbaa That sounds like the WSL issue here: https://github.com/microsoft/wslg/issues/1212. This also means that specific issue is not related to WT, and could be repro on other terminals (Eg. VS, VSCode)
Author
Owner

@snip3rnick commented on GitHub (Apr 15, 2024):

I have been facing the same issue consistently when opening the WT through the Windows 11 start menu or PowerToys Run.
By my observation this occurs after one Window of WT is already open somewhere, which I do have at all times.
The new terminal window seemingly is placed in the Window stack on top of the topmost existing WT Window.

  • WT Version: 1.19.10573.0
  • WinVer: Win11 23H2 (22631.3296)

I could see this being resolved by forcibly ordering the new window on top of the Window stack with the HWND_TOPMOST flag in a SetWindowPos call right after the window creation.
I acknowledge that I have not looked at the implementation which may already include this or similar.

@snip3rnick commented on GitHub (Apr 15, 2024): I have been facing the same issue consistently when opening the WT through the Windows 11 start menu or [**PowerToys Run**](https://github.com/microsoft/PowerToys). By my observation this occurs after one Window of WT is already open somewhere, which I do have at all times. The new terminal window seemingly is placed in the Window stack on top of the topmost existing WT Window. - WT Version: 1.19.10573.0 - WinVer: Win11 23H2 (22631.3296) I could see this being resolved by forcibly ordering the new window on top of the Window stack with the `HWND_TOPMOST` flag in a `SetWindowPos` call right after the window creation. I acknowledge that I have not looked at the implementation which may already include this or similar.
Author
Owner

@Youngerkind commented on GitHub (May 4, 2024):

For the version (1.19.11213.0, released on May 4th, 2024), the problem seemed solved. New window can be created on the top of the old window. But that is not the case if new windows are created on a different desktop:

If I open one window at one virtual desktop, switch to another virtual desktop, open a new window and close it. From now on, the new created window will lose the focus, thought the cursor blinking.

I find this from about one year ago and use the preview one downloaded here, instead of that installed in the Microsoft store.
I need this feature for that, I always open several terminal windows on several desktops, some for remote ssh, some for local wsl and so on.

@Youngerkind commented on GitHub (May 4, 2024): For the version (1.19.11213.0, released on May 4th, 2024), the problem seemed solved. New window can be created on the top of the old window. But that is not the case if new windows are created on a different desktop: If I open one window at one virtual desktop, switch to another virtual desktop, open a new window and close it. From now on, the new created window will lose the focus, thought the cursor blinking. I find this from about one year ago and use the preview one downloaded here, instead of that installed in the Microsoft store. I need this feature for that, I always open several terminal windows on several desktops, some for remote ssh, some for local wsl and so on.
Author
Owner

@MolotovCherry commented on GitHub (May 4, 2024):

I tried the new prelease. Problem still happens to me. Any subsequent launches after the first have their windows go behind everything else, regardless whether the launch was from context menu or app shortcut in the taskbar search

Edit: just realized my comment sounds a bit snarky. That was not intended. I read the above comment wrong thinking it was solved in the new version, and wanted to make it clear it still happens for me

@MolotovCherry commented on GitHub (May 4, 2024): I tried the new prelease. Problem still happens to me. Any subsequent launches after the first have their windows go behind everything else, regardless whether the launch was from context menu or app shortcut in the taskbar search Edit: just realized my comment sounds a bit snarky. That was not intended. I read the above comment wrong thinking it was solved in the new version, and wanted to make it clear it still happens for me
Author
Owner

@snip3rnick commented on GitHub (May 4, 2024):

I can confirm that the behavior does persist with ne new version on my system as well.
When startet using PowerToys Run or the explorer context menu the new terminal will open as the second topmost window.
Interestingly though when opened with the Windows start menu it opened behind every other window (even other terminals).

I hope hope this can be resolved, I am happy with the terminal application regardless. It would just add convenience if the opened terminal was visible and had keyboard focus.

If I can find the time I will try to help in finding a workaround.

@snip3rnick commented on GitHub (May 4, 2024): I can confirm that the behavior does persist with ne new version on my system as well. When startet using PowerToys Run or the explorer context menu the new terminal will open as the second topmost window. Interestingly though when opened with the Windows start menu it opened behind every other window (even other terminals). I hope hope this can be resolved, I am happy with the terminal application regardless. It would just add convenience if the opened terminal was visible and had keyboard focus. If I can find the time I will try to help in finding a workaround.
Author
Owner

@tusharsnx commented on GitHub (May 4, 2024):

If I can find the time I will try to help in finding a workaround.

You know what, if you just ensure that any window of the terminal is focused when the new window is starting up, the new window always starts in the foreground.

And same goes for when no window of the terminal has focus, the new window starts behind all other windows on the screen😕

It doesn't work as a workaround though, because only the foreground window (or its process) can request to change the foreground window to a different one.

@tusharsnx commented on GitHub (May 4, 2024): > If I can find the time I will try to help in finding a workaround. You know what, if you just ensure that any window of the terminal is focused when the new window is starting up, the new window always starts in the foreground. And same goes for when no window of the terminal has focus, the new window starts behind all other windows on the screen😕 _It doesn't work as a workaround though, because only the foreground window (or its process) can request to change the foreground window to a different one._
Author
Owner

@whitestrake commented on GitHub (May 29, 2024):

I have some different behaviours depending on launch method, but for me, it seems to only be failing with the Quake console active.

Launch method Quake console exited Quake console running
Win+X, I Foreground, active Foreground, inactive
Win+R, "wt", Enter Foreground, active Background
Win, "wt", Enter Foreground, active Foreground, active
Win, "terminal", Enter Foreground, active Background
@whitestrake commented on GitHub (May 29, 2024): I have some different behaviours depending on launch method, but for me, it seems to only be failing with the Quake console active. | Launch method | Quake console exited | Quake console running | | --- | --- | --- | | `Win+X`, `I` | ✅ Foreground, active | ⛔ Foreground, inactive | | `Win+R`, "wt", `Enter` | ✅ Foreground, active | ⛔ Background | | `Win`, "wt", `Enter` | ✅ Foreground, active | ✅ Foreground, active | | `Win`, "terminal", `Enter` | ✅ Foreground, active | ⛔ Background |
Author
Owner

@AldieNightStar commented on GitHub (Jun 2, 2024):

Started to open on background always. Only win + "wt" is working on active. But i want to open in current directory. So i have to hide all windows to find terminal. Strange update

@AldieNightStar commented on GitHub (Jun 2, 2024): Started to open on background always. Only `win` + `"wt"` is working on active. But i want to open in current directory. So i have to hide all windows to find terminal. Strange update
Author
Owner

@n00mkrad commented on GitHub (Jun 4, 2024):

Same issue. Also happens when run through "Send To" shortcut or when started through Flow Launcher.

@n00mkrad commented on GitHub (Jun 4, 2024): Same issue. Also happens when run through "Send To" shortcut or when started through Flow Launcher.
Author
Owner

@zadjii-msft commented on GitHub (Aug 29, 2024):

This may have been fixed by #17368 in 1.22 Preview - can anyone confirm/?

@zadjii-msft commented on GitHub (Aug 29, 2024): This may have been fixed by #17368 in 1.22 Preview - can anyone confirm/?
Author
Owner

@AshleyScirra commented on GitHub (Aug 30, 2024):

The steps I described in this comment no longer reproduce for me with Windows Terminal v1.20.11781.0 on Windows 11 23H2 (build 22631.4037). Glad it's working as this had been bugging me for ages!

@AshleyScirra commented on GitHub (Aug 30, 2024): The steps I described in [this comment](https://github.com/microsoft/terminal/issues/15479#issuecomment-1895644698) no longer reproduce for me with Windows Terminal v1.20.11781.0 on Windows 11 23H2 (build 22631.4037). Glad it's working as this had been bugging me for ages!
Author
Owner

@pTinosq commented on GitHub (Sep 2, 2024):

This may have been fixed by #17368 in 1.22 Preview - can anyone confirm/?

@zadjii-msft Can confirm that this is working for me! Thanks so much

Windows information:
Edition Windows 11 Business
Version 23H2
Installed on ‎22/‎09/‎2023
OS build 22631.4037
Experience Windows Feature Experience Pack 1000.22700.1027.0

@pTinosq commented on GitHub (Sep 2, 2024): > This may have been fixed by #17368 in 1.22 Preview - can anyone confirm/? @zadjii-msft Can confirm that this is working for me! Thanks so much Windows information: Edition Windows 11 Business Version 23H2 Installed on ‎22/‎09/‎2023 OS build 22631.4037 Experience Windows Feature Experience Pack 1000.22700.1027.0
Author
Owner

@microsoft-github-policy-service[bot] commented on GitHub (Sep 7, 2024):

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@microsoft-github-policy-service[bot] commented on GitHub (Sep 7, 2024): This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for **4 days**. It will be closed if no further activity occurs **within 3 days of this comment**. <!-- Policy app identification https://img.shields.io/static/v1?label=PullRequestIssueManagement. -->
Author
Owner

@maxkagamine commented on GitHub (Aug 16, 2025):

This still happens in 1.22.12111.0 (Win10). No issue when launching from the taskbar, but when using the "Open in Terminal" option in explorer's context menu, the terminal opens behind the explorer window. (Confirmed in a VM with a fresh install, as well.)

https://github.com/user-attachments/assets/5b69b1b1-65a7-492a-a8a9-c0cc78b1b87f

@maxkagamine commented on GitHub (Aug 16, 2025): This still happens in 1.22.12111.0 (Win10). No issue when launching from the taskbar, but when using the "Open in Terminal" option in explorer's context menu, the terminal opens behind the explorer window. (Confirmed in a VM with a fresh install, as well.) https://github.com/user-attachments/assets/5b69b1b1-65a7-492a-a8a9-c0cc78b1b87f
Author
Owner

@marbaa commented on GitHub (Aug 21, 2025):

I can't reopen the issue.
Termianl Canary Version: 1.24.2321.0

When opening new terminal window with ctrl + click (as administrator) from dropdown menu, then new window is opened all the time in background.

Gray window is only instance running, black window is the one opened from ctrl + click in dropdown menu.
Image

@marbaa commented on GitHub (Aug 21, 2025): I can't reopen the issue. Termianl Canary Version: 1.24.2321.0 When opening new terminal window with ctrl + click (as administrator) from dropdown menu, then new window is opened all the time in background. Gray window is only instance running, black window is the one opened from ctrl + click in dropdown menu. <img width="2192" height="1362" alt="Image" src="https://github.com/user-attachments/assets/b3d7648f-ead1-4757-8bfd-efe00c163fd1" />
Author
Owner

@peter-fb commented on GitHub (Nov 22, 2025):

I'm still seeing this with version 1.23 on Windows 10.

@peter-fb commented on GitHub (Nov 22, 2025): I'm still seeing this with version 1.23 on Windows 10.
Author
Owner

@marbaa commented on GitHub (Nov 24, 2025):

That is ridiculous. Can some of the MS AI agents open back the issue? Issue is not solved.

@marbaa commented on GitHub (Nov 24, 2025): That is ridiculous. Can some of the MS AI agents open back the issue? Issue is not solved.
Author
Owner

@AshleyScirra commented on GitHub (Nov 24, 2025):

The steps I described in this comment still don't reproduce this issue for me with Windows Terminal v1.23.12811.0 on Windows 11 25H2 (build 26200.7171). So it still seems fine for me.

@AshleyScirra commented on GitHub (Nov 24, 2025): The steps I described in [this comment](https://github.com/microsoft/terminal/issues/15479#issuecomment-1895644698) still don't reproduce this issue for me with Windows Terminal v1.23.12811.0 on Windows 11 25H2 (build 26200.7171). So it still seems fine for me.
Author
Owner

@lhecker commented on GitHub (Nov 24, 2025):

...it's also somewhat unlikely to a bug on our side anymore at this point. As an example, do the following on Windows 11:

  • Search for "notepad" in the start menu (make sure it's the new one, the one with the slow startup)
  • Press Enter
  • Immediately hold Shift or Ctrl as quickly as possible
  • ---> Notepad starts in the background and just blinks in the taskbar

If you do the same without holding a modifier key, it'll start in the foreground. I would not be surprised if Explorer and the start menu have (or had) similar bugs elsewhere.

@lhecker commented on GitHub (Nov 24, 2025): ...it's also somewhat unlikely to a bug on our side anymore at this point. As an example, do the following on Windows 11: * Search for "notepad" in the start menu (make sure it's the new one, the one with the slow startup) * Press Enter * _Immediately_ hold Shift or Ctrl as quickly as possible * ---> Notepad starts in the background and just blinks in the taskbar If you do the same without holding a modifier key, it'll start in the foreground. I would not be surprised if Explorer and the start menu have (or had) similar bugs elsewhere.
Author
Owner

@marbaa commented on GitHub (Nov 26, 2025):

Yes, your steps will put Notepad into background. For terminal I could reproduce 100% times, that it put new window into background while 'ctrl + click' or 'shift + click' from "+" dropdown menu.

Yesterday and today I got some Windows updates, also I updated Terminal to v1.25.3281.0 and new window is now put in background randomly. Not all the time.

@marbaa commented on GitHub (Nov 26, 2025): Yes, your steps will put Notepad into background. For terminal I could reproduce 100% times, that it put new window into background while 'ctrl + click' or 'shift + click' from "+" dropdown menu. Yesterday and today I got some Windows updates, also I updated Terminal to v1.25.3281.0 and new window is now put in background randomly. Not all the time.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#20010