terminal icon indicating copy to clipboard operation
terminal copied to clipboard

Feature request: hot key drop down ala quake/guake/tilda

Open NOFUNEVER opened this issue 7 years ago • 147 comments

The petty thing I miss most when I pop into Windows is having a separate hot key terminal for each of my three monitors. The closest i've ever been to believing in god was when I realized that was obtainable and if you could make that happen in Windows I just might have to kiss you.

NOFUNEVER avatar May 10 '19 05:05 NOFUNEVER

Nevertheless it seems that this issues might not make it even into the release in 1 year. Too bad. I was very keen to use the new terminal but without the hot key feature it’s too cumbersome compared to guake on linux.

Defcon0 avatar Jun 11 '20 21:06 Defcon0

Happy it made the list at least. :) - WSL2 Docker has made Windows a more doable daily driver, this feature will just push it further when it lands.

TheBrigandier avatar Jun 11 '20 22:06 TheBrigandier

I agree that this is a handy feature, and I would really need this if I use Windows. However, all mentioned functionalities should be handled by the window manager, instead of a terminal.

eggeek avatar Jun 12 '20 01:06 eggeek

Technically that would be optimal if WM allowed that, you'd be able to handle all and every window with ease but it's unlikely we'll get that soon. The best bet would be adding that to PowerToys

zakius avatar Jun 12 '20 11:06 zakius

Not neccessarily. It just means that Microsoft staff won't work on it. Anyone can submit the feature as a PR.

oising avatar Jun 12 '20 16:06 oising

If anybody wants a very simple AutoHotkey solution, see gist: https://gist.github.com/atruskie/99a498ac43b91deb91eab4069b6047b9

It's not the exact solution, but it does the job without much effort.

#NoEnv
#SingleInstance force
SendMode Input
DetectHiddenWindows, on
SetWinDelay, 0

#`::
    terminal := WinExist("ahk_exe WindowsTerminal.exe")
    if (terminal) 
    {
        active := WinActive("ahk_id " terminal)
        if (active)
            WinMinimize, ahk_id %active%
        else
            WinActivate, ahk_id %terminal%
    }
    else
        Run, wt.exe
Return

humanfactors avatar Jun 15 '20 14:06 humanfactors

@Defcon0 I just put it as the first entry in my task bar and use WIN + 1, it's honestly a little more convenient for me since I can place it anywhere on the screen.

@Jaykul provided one step opening in admin as well

chazt3n avatar Jun 15 '20 19:06 chazt3n

If anybody wants a very simple AutoHotkey solution, see gist: https://gist.github.com/atruskie/99a498ac43b91deb91eab4069b6047b9

It's not the exact solution, but it does the job without much effort.

#NoEnv
#SingleInstance force
SendMode Input
DetectHiddenWindows, on
SetWinDelay, 0

#`::
    terminal := WinExist("ahk_exe WindowsTerminal.exe")
    if (terminal) 
    {
        active := WinActive("ahk_id " terminal)
        if (active)
            WinMinimize, ahk_id %active%
        else
            WinActivate, ahk_id %terminal%
    }
    else
        Run, wt.exe
Return

I wrote a gist like this a while ago: https://gist.github.com/sharunkumar/af7ba56e3cce8238ae9c986c619e8d1c

this one switches back to the active window which you were in, before you switched to WT

global PreviousActiveWindow

#`::
DetectHiddenWindows, On
if (WinExist("ahk_class CASCADIA_HOSTING_WINDOW_CLASS")) {
	if(WinActive("ahk_class CASCADIA_HOSTING_WINDOW_CLASS")) {
		WinActivate, ahk_id %PreviousActiveWindow%
	} else {
		WinGet, PreviousActiveWindow, , A ; 'A' for currently active window
		WinActivate, ahk_class CASCADIA_HOSTING_WINDOW_CLASS
	}
} else {
	TerminalLink = %localappdata%\Microsoft\WindowsApps\wt.exe
	if FileExist(TerminalLink) {
		WinGet, PreviousActiveWindow, , A ; 'A' for currently active window
		Run, %TerminalLink%
	} else {
		MsgBox, Windows Terminal not installed
	}
}
Return

sharunkumar avatar Jun 16 '20 08:06 sharunkumar

I found this repository for a simple app that add quake to the terminal: https://github.com/flyingpie/windows-terminal-quake

Works well enough for my use cases.

Belphemur avatar Jun 19 '20 01:06 Belphemur

I found this can be easily achieved using the Keyboard Manager PowerToy and the aforementioned Windows Key + NUM shortcut to launch an application pinned to your taskbar. Simply pin the Windows Terminal to your task bar (mine is in position 6) and then open the PowerToys Keyboard Manager tool. I have used WIN + ` with Cmder and so remapped the shortcut WIN + ` to WIN + 6. Now, whenever I do WIN + ` the Windows Terminal will come to the front or will launch a new instance if it's not already running (which is even better than what Cmder does natively).

image

mattscully avatar Jun 23 '20 13:06 mattscully

no, it's not the same thing minimize != hide window window hiding makes it get out of your way completely

zakius avatar Jun 23 '20 14:06 zakius

You are correct, this is certainly not quake mode--sorry for any confusion. I found this issue just looking for a way to have a custom global shortcut bring the Terminal to the foreground which was a deal breaker for me as I'm used to that behavior from Cmder. Personally, I haven't felt a need for Quake mode so this shortcut solution filled the gap and so I thought I would pass it along.

mattscully avatar Jun 23 '20 16:06 mattscully

This is the most upvoted feature request and has been open for over a year??

How the hell is this not implemented yet?

nofunatall avatar Jul 03 '20 00:07 nofunatall

Hey I'm just posting some research notes here, because I don't want to lose them.

RegisterHotKey didn't seem to do anything in my experimentation. Maybe I was doing it wrong? Maybe the XAML Island is eating the WM_HOTKEY message before it even gets to our wndproc? There doesn't seem to be any feedback on that function anyways, so I'm not sure how helpful that is in a "multi instance mode".

SendMessage(_window.get(), WM_SETHOTKEY, VK_OEM_3, 0) actually did work. It even returns 2 if there's another window with that hotkey already set, which is nice. That'll do everything for us - when the key is pressed anywhere on the system, it'll activate the Terminal window, even if it's minimized. Unsure about "minimized to taskbar", but progress is progress.

Unfortunately, it's not trivial to have a second Terminal Window wait for the first window to close, and then have it pick up the hotkey. Plus, who gets the hotkey if there are 3 opened WT windows? So right now, only the first window would get the hotkey assigned to it, and then any subsequent windows created wouldn't get the hotkey assigned to them, until the first window is closed. Then, the next WT window created would get the hotkey. That's certainly awkward.

Settings reloading would probably also result in a random WT window getting the hotkey assigned.

There's a bunch of asks in this thread, so I'm gonna try and summarize them, but not prescribe a holistic solution yet.

  • Press a hotkey anywhere to activate the single Terminal window wherever it was (requires single-instance mode, as well as global hotkey support)
  • Press a hotkey anywhere to activate the single Terminal window on the current monitor. If it wasn't previously on that monitor, move it there. (requires single-instance mode, as well as global hotkey support)
  • Press a hotkey to activate the "nearest" terminal window. (This will probably require some IPC like what #5000 is working on)
  • Minimize to tray, press a hotkey to activate the single terminal window / the nearest terminal window (#5727)
  • Terminal doesn't appear in alt+tab view, press a hotkey to activate the single terminal window / the nearest terminal window (I'm not sure this is distinct from the above
  • when the Terminal is summoned using the hotkey, have it "slide in" from the top (Unsure if this is possible with the SendMessage(WM_SETHOTKEY) method above.)
    • Similarly, slide out on deactivate?

Wow I'm sure that I missed some of the scenarios covered in the 95 comments on this thread, but already that's a mess of settings.


EDIT 17-Aug-2020: Oh hey this is how PowerToys hooks the keyboard for global messages, lets just do that. https://github.com/microsoft/PowerToys/blob/49b56d9b52bdfedd6ad1404bd0b20e884d2b574b/src/modules/shortcut_guide/shortcut_guide.cpp#L150-L173

zadjii-msft avatar Jul 20 '20 22:07 zadjii-msft

In my humble opinion minimizing to tray sounds like a different feature.

Having multi-instances and having different instances summoned on different displays sounds like something for a second iteration of this feature.

I think it would be better to first concentrate on simpler scenarios, like a single instance being summoned via slide-in on a hotkey and slide-out on the same hotkey. If there are multi-instances there should be probably a rule which one gets summoned then

Croydon avatar Jul 27 '20 12:07 Croydon

IMO, as WT has multiple tabs, best scenario is one instance and get summoned where mouse is, if there are multiple virtual desktops or monitors. Like Guake.

markkrj avatar Aug 09 '20 02:08 markkrj

Hi @zadjii-msft -- I have been looking at some similar areas as well and I wanted to consolidate the research along with sharing some implementations thoughts. Reading through the materials, I couldn't be sure if I was missing where the team's looked at ways to leverage UAP/UWP features that might be relevant so hopefully this isn't already-trodden ground!

First off, the hot key registration. I found the WM_HOTKEY research you did complementary to this UWP hotkey registration route outlined here. Is this an approach you've already considered? I thought it could be a nice approach, since the "launch windows terminal here" explorer context menu has already been implemented, removing the need to build/test the AppService/IPC (#5000) since we could simply extend and enhance what's already there.

While digging into this, I came across this possibly relevant SO answer outlining an approaching that attaches to the Windows.UI.Core.CoreDispatcher.AcceleratorKeyActivated in order to receive notifications when special key combos are pressed e.g., CTRL+~. Is this something that might be applicable?

Speaking of the process model...

Unfortunately, it's not trivial to have a second Terminal Window wait for the first window to close, and then have it pick up the hotkey. Plus, who gets the hotkey if there are 3 opened WT windows? So right now, only the first window would get the hotkey assigned to it, and then any subsequent windows created wouldn't get the hotkey assigned to them, until the first window is closed. Then, the next WT window created would get the hotkey. That's certainly awkward. Settings reloading would probably also result in a random WT window getting the hotkey assigned.

There's a common thread with these challenges that, once plucked out of the equation makes things much more clear and simple. That common thread is the logic and complexity involved in wt instance management - I think that much of the rest is fallout from that core challenge. Like many challenges, this one might be best solved by breaking it down into smaller challenges. Here, I think that introducing an intermediary makes it unnecessary for WT to need to know anything about instance management, let alone handling global (e.g., application isn't in focus) hot key registration and binding. This appeals to me from the SRP standpoint, and it seems to me that the work to provide the "launch Windows Terminal Here" explorer context menu aligns with this conceptually, if not in reality. The UWP desktop extensions' TriggerEvent can be used by IPC services to pass serialized Actions (commands) to running wt instances or parsed and passed as launch args for new wt processes

The process handling the global hotkey would be both a system tray application and be a single-instance mode process (likely a WinForms app) that contains a NotifyIcon component along with the system tray icon's context menu and dispatcher components. This has a positive side-effect of obviating the need to add a lot of new and complicated settings+logic to the WT codebase, since wt won't need to know anything about a so-called "quake mode" :smile:. The systray application would be the source/repository for these types of settings, and which I think will absolutely work with and benefit from #7170

  • Press a hotkey anywhere to activate the single Terminal window wherever it was (requires single-instance mode, as well as global hotkey support)

The systray app's context menu could have a flyout that displays a list of wt profiles that users can click to select the profile to use when invoked "in the style of Quake Mode". It might default to the first profile listed if unspecified. If there are plans/specs for implementing internal logic for getting lists of profiles and their details, the design would benefit from the ability to be used outside of the wt.exe process (as in, the notifyicon application shouldn't have to duplicate functionality to load the list of profiles and such if at all possible). Because the systray app manages instances, wt does not necessarily need to implement single-instance mode itself. The PowerToys repos shows the UWP IPC decls in the manifest and likely has more useful nuggets.

Summing up an already info-dense post:

Most of the bulleted concerns disappear or are greatly mitigated with this approach if you think about it. When I take a step back and look at the whole, I feel that this feature is closer to becoming a reality this than we thought!

  • Press a hotkey anywhere to activate the single Terminal window on the current monitor. If it wasn't previously on that monitor, move it there. (requires single-instance mode, as well as global hotkey support)

  • Press a hotkey to activate the "nearest" terminal window. (This will probably require some IPC like what #5000 is working on)

  • Minimize to tray, press a hotkey to activate the single terminal window / the nearest terminal window (#5727)

  • Terminal doesn't appear in alt+tab view, press a hotkey to activate the single terminal window / the nearest terminal window (I'm not sure this is distinct from the above

  • when the Terminal is summoned using the hotkey, have it "slide in" from the top (Unsure if this is possible with the SendMessage(WM_SETHOTKEY) method above.)

    • Similarly, slide out on deactivate?

Resources for NotifyIcon, WinForms, and WPF: http://www.abhisheksur.com/2012/08/notifyicon-with-wpf-applications.html https://www.codeproject.com/articles/36788/wpf-xaml-notifyicon-and-taskbar-system-tray-popup https://mcguirev10.com/2019/01/27/system-tray-icons-wpf-net-core-preview.html

HTH!

EDIT: Reading through the draft process model specs, it seems you have also identified the separate process approach. I suppose that the part of the "monarch" could in part or maybe(?) in whole played by the IPC/appservice

jelster avatar Aug 27 '20 16:08 jelster

I made a quick&dirty utility that register global hotkey to toggle last Windows Terminal window. I think it would be a nice workaround before official implementation.

https://github.com/Inndy/TerminalSummoner

Inndy avatar Aug 28 '20 17:08 Inndy

I modified an autohotkey solution from https://github.com/ehpc/quake-windows-bash for a little better user experience. I haven't looked into @Inndy 's solution so it may be better.

My script is located here: https://github.com/rengler33/dotfiles/blob/master/C/Users/Rub/wt-quake-like.ahk

Using the hotkey Ctrl + `

  1. If windows terminal is not launched, it launches it*
  2. If it's launched but minimized, it's restored
  3. If it's active, it gets minimized
  4. Otherwise (meaning it's restored but out of focus), bring it into focus

*Note: this script also uses a Windows shortcut that I like to use that adds a few options on opening https://github.com/rengler33/dotfiles/blob/master/C/Users/Rub/wt.exe.lnk But could be replaced to simply launch BashHandle instead instead of Shortcut

rengler33 avatar Sep 19 '20 17:09 rengler33

I modified an autohotkey solution from https://github.com/ehpc/quake-windows-bash

Thanks for that.

I got inspired by @rengler33 's script and did some modifications for my own 3-screen setup: https://gist.github.com/oryon-dominik/562970f77f2ad4d9bd57bea58ddc8ef5 The script spawns a Windows-Terminal on the active screen. (CTRL+CIRCUMFLEX) Bad animations and a bit of flickering though, so it's more of a workaround.

I'm really looking forward to get this feature officially implemented..

oryon-dominik avatar Sep 21 '20 21:09 oryon-dominik