Hacker News new | past | comments | ask | show | jobs | submit login
Window-Switcher: Alt+(backtick) same-app window switching for Windows 10/11 (github.com/sigoden)
50 points by danso 4 months ago | hide | past | favorite | 58 comments



And conversely https://alt-tab-macos.netlify.app/ to keep your sanity on macOS.

The things that annoys me most atm: when I have multiple VS Code windows, and my web browser, if I Cmd+Tab from my web browser to VS Code _all_ the VS Code windows pop to the foreground, even ones I'm not focusing. In other words, I can't write code and also be able to see the result at the same time. Just because I choose to have stuff I'm not working on that's completely irrelevant to the thing at hand being behind other things I am working on. Unless I spend time manually putting windows in non-preferred locations or closing things or doing things that are in no way related to the things I have visible and am working on right now at the moment.

And if I minimise then I have to minimise again if I Alt+` through the application windows. It's just all so very very tedious on macOS. Wouldn't want to use it if it wasn't for work.


This behavior and macOS’s terrible default window management ultimately drove me back to Windows for serious work. I suppose I never fully adapted to the macOS way of doing things, but I never understood what they envisioned users were supposed to do here. Is the intended behavior that the user minimize any VSCode windows that are not currently in use?

But then what if I have multiple windows open because the other has some reference codebase? Do I keep that in a separate desktop instead? It’s just perplexing.


This is where you see the NeXTSTEP under the hood :-). A very long time ago, this made perfect sense, as applications from that era were multi-window. You can sort of see how it worked here: https://www.paullynch.org/NeXTSTEP/NeXTSTEP.screenshot.jpg (no affiliation, just the first relevant Google result). The Mailboxes window (to the right) and the email display window (in the background, just behind the File Viewer window) were separate, but they were part of the same application. That's why moving all of the application's windows to the foreground when switching to that application was the right call back then, the expectation was that you'd usually run a single instance of that application, and that application would have any number of windows. IIRC if you didn't need one of them too frequently, you would just iconify it.

Contemporary applications (especially cross-platform lowest common denominator applications, like most Electron apps) don't really do that anymore. Pretty much every modern email client has the mailboxes view in a side pane or something, whereas NeXT would have the email view, the mailbox view, address book views etc. all in separate windows. If VS Code has multiple windows, they act pretty much like fully separate instances. It's just not the kind of multi-window application that (what eventually developed into) the modern macOS UI was built for.

Edit: this has been, at various times, been retrofitted onto various contemporary design notions in terms of simplicity or intuitiveness. That's 100% ivory tower bull: this interaction model was pretty common on late 80s/early 90s interfaces, especially on Unices, and everyone gradually moved away from it precisely because it was anything but simple or intuitive, it was confusing as hell. Even as early as the early '00s it had gone out of fashion, and holdouts were just plain weird. E.g. GIMP used to have this mode (and just this mode) in its 1.x-releases and if you asked anyone why they hated it, that was their first answer, before they got to everything Photoshop did and GIMP didn't.


It is a windowing system built for one monitor and one desktop. Its metaphors broke completely once they added multi monitor multi desktop per monitor support.

Even the menu bar does not make any sense when you have two monitors. Let alone the useless command tab that picks up whichever window (or not even a window) it wants


Only Gnome does multi-desktop really well in my opinion.

Unless Windows has fixed things, I found that windows alerting on an alternative virtual desktop could lock everything until I found the popup. There were plently of other sharp edges.


Same. I got a company provided MacBook and used it as my daily driver for a few years. Really tried to buy into the ecosystem. But some things just felt so clunky, so when next laptop replacement came after ~3 years it was back to Windows.

Which I'm not also always a big fan of. But the basic interactions just make more "sense" in my head. I thought it was just familiarity in the beginning, but even after getting familiar with my OS X (at the time) I didn't become effective.

In the same vein, I upgraded to Win11, but downgraded after a month because of the new useless task bar. It couldn't "ungroup" stuff. Had to wait for over a year before that came and I upgraded again. Not being able to see all my open windows on the task bar felt exactly as using MacOS again, just stupidly unproductive, why change a winning formula, Microsoft? (My guess is their designers use Mac and don't "get" Windows..)


Cmd+tab, then Cmd+`

I much prefer it to alt-tabbing through every single open window. I don't understand why people prefer that.


Simplicity.

You have one key combination: Alt+Tab. (Alt+Shift+Tab to go in reverse, if you're fancy.)

You have one list of windows, also visible on the taskbar.

People worship simplicity. Life is busy enough without more arcane voodoo rituals to make sand think.


This does not scale well with the number of windows, e.g. going to the next pdf open might mean cycling through half your windows. Hence you get grouping to make this simpler. Whether it should be grouping by app, by virtual desktop, by time opened, "smart", manual, whatever is another discussion.


You cycle through most recent window that you used... there is no grouping that would get in the way.


I suppose this makes sense if you have relatively few windows that each themselves encompass self-contained task state: one terminal window with a bunch of tabs, one VS Code window with a bunch of tabs, and so on.

I've always found this rather, uh, un-simple to deal with because I both suffer from attention problems and because I tend to want to consider a whole box of windows together as a complete task. macOS's per-appbundle model, inherited from NeXTstep, isn't perfect, but it does at least get closer to what I want.

I used to write software in Delphi, and Alt-Tabbing through several forms and code windows and panels and hypertext documents and compiler error listings and whatnot was just a gigantic pain. It really, really soured me on Windows' way of doing things: I could just never get the mental model down for how windows would stack in the Alt-Tab order given my need to flip between six or seven of them somewhat randomly in the course of working on something.


Yes, but...Windows makes me crazy for the opposite reason. Outside of the simple toggle-back-and-forth case you describe (which is super annoying, yes), it's incredibly hard to get to a different VSCode window, because you have to step through who knows what irrelevant other app windows to get there. Cmd-` on the Mac takes you straight there. And there are apps with multiple windows (e.g., KiCad) where you really do want to switch to all the app windows at once -- most of the time.

Also, on MacOS, things get easier if you use Spaces to organize different tasks, so there's less overlap of completely irrelevant windows.

So, on any platform, what I want is all three switching commands, because they're all the right thing in different situations.


On macOS, you can actually raise just the window you want but its more key presses.

Cmd+Tab until the application you want is highlighted, then keep holding Cmd and press 1, you'll then be shown all open windows for that application (you can stop holding Cmd) now use arrow key to select the window you want and press enter. Only that window will be raised.


I recently released https://robata.app. It provides a view of all your windows, allowing you to select the one you want. It's slightly different from Alt-Tab, but you might find it useful. I've also added Alt-Tab-like shortcuts in the next version to be released.


Using Stage Manager or multiple desktops is a more efficient way of grouping windows and switching between them. Trying to reorder windows constantly with alt-tab is tedious.


Since we are talking about window switching, a little rant:

there are two common orders for switching windows/tabs: most recently used, and sequential. Some use the first one (e.g. Windows), some use the other (e.g. most browsers). They both have their merits, so people prefer one or the other.

Yet, almost no software provide a toggle to customize this (Firefox does, but it has an even weirder quirk).

I understand modern software can't have billions of settings for every single thing for (good) practical reasons, but deep in my heart, I'm still annoyed by the fact "we have all the technology, yet we still have to compromise to this".


Oddly enough, I much prefer recently used when switching windows and sequential when switching tabs.

I'll note as well that Vivaldi offers the option to switch the behavior.


> Oddly enough, I much prefer recently used when switching windows and sequential when switching tabs.

Same! The key difference IMO is that with tabs, I can actively see all of them even before I hit the shortcut; being able to see the "distance" between my current tab and the "destination" makes me find linearly searching easier.

With windows, I tend to almost always have things maximized on the monitor they're on, and when I have two monitors, I tend to split things by only having a single window on one monitor (keeping the rest all together). While there's generally a visual reference for swapping windows once you've hit the shortcut (but haven't released it yet), not having the context before I start taking action makes me less likely to know the exact order of my windows, so there's not really any order that would be helpful based on that. The only reason that recency order is somewhat useful for me is to be able to quickly swap back and forth between two apps (especially when I have a single monitor), and that's just not really how I use tabs.


It is probably what was learned where, muscle memory can be a strange thing at times. I, for instance, enjoy the vi editor, to the point that I have a hard time using emacs, however, I need the emacsish keybindings in my shell and don't like the vi keys there.


> Yet, almost no software provide a toggle to customize this (Firefox does, but it has an even weirder quirk).

What is the quirk? I enable the "recently used order" immediately when installing Firefox.


It automatically enables the preview feature, which I absolutely don't want (less about the preview itself, more about the fact when the preview is enabled, the tabs won't actually switch (so you can see the content in tab) until you release the hotkeys.

There used to be two separate switches (as it should be), but one core developer (Dão Gottwald) arbitrarily decided to merge the two together, despite multiple oppositions in the thread [1], because he thought "[w]ithout previews, switching in recently used order between more than two tabs would be unusable".

I'm still salty about this after all the years, not because how the feature I liked was gone, but it's the first first-hand experience I had that shows how the direction of OSS projects can be dictated by a single person and you can do nothing about it.

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=1335108


Well, the final switch can't really happen until you release "Ctrl", otherwise the feature would be broken... and it has to be indicated somehow that the switching mode is active...

But would still like to switch between 20 or more or more most recent tabs, not just 7.


Vivaldi has the keybinds for both options of tab cycling, and on Windows you could also have both via a script/app, so no need to compromise in these basic

(and unfortunately most often there aren't really good reasons for having such a poor customization for most apps, just bad design without much care for UI)


I miss these macOS shortcuts when I am other platforms. For Windows, I wrote my own extensive AHK scripts to duplicate most Mac shortcuts I regularly use, including cursor movement

On Linux I now use Toshy

https://github.com/RedBearAK/toshy


This is one of my essential quality of life tools:

https://github.com/rbreaves/kinto

Decades of using the Mac convention of CMD instead of CTRL makes it hard to switch to CTRL. I get cramping super quickly when using Windows or Linux without Kinto!

Of course, try explaining that to corporate IT who insist you use a locked down Windows PC... thank god I dont have to endure that anymore!


If you love Kinto, you need to really look at the Toshy project. It is a fork of Kinto for Linux. The developer of Toshy is super active and responsive, and has moved the Kinto code to more modern technology. They have refactored the scripts to be much easier to customize and while allowing upgrade to new versions of Toshy.

https://github.com/RedBearAK/toshy


Thanks!

I'll check it out!


> ... CTRL. I get cramping super quickly

The trick to CTRL is pressing it with your palm.

http://xahlee.info/kbd/how_to_press_control_key.html


You know what, I'll try that!

Save me contorting my little finger.

Although I wish we could go back CTRL defaulting to where CAPSLOCK is!


You have those AHKs somewhere online? Would love to peruse them...


I had to clean up the code a bit and move it to a public GitHub repository.

https://github.com/leejoramo/macOS-plus-AHK

As others have mentioned it is probably worth looking at Kinto to add macOS keyboard shortcuts to Windows. I started this project years before I learned about Kinto, plus I have most of my other system customizations in here.

Currently my main workstation is KDE/Ubuntu where I use Toshy for the macOS shortcuts, and have customized the rest via KDE shortcut management and my hardware keyboard.


For the 'cycle windows of current app', i've posted a function above https://news.ycombinator.com/item?id=41288792


Thanks for making this, but small note:

On QWERTZ, backtick ` is: a dead key, situated left of backspace, and it's in the "upper row", too.

So there the combo is actually Alt+Shift+´+Space, in need of two hands - it's very hard to imagine a worse default key combo choice for this task, compared to Alt+Tab. I'm glad you made it configurable.

Fun fact: one of the first public drafts for multi-line Strings in Java expected the delimiter to be ```, until I pointed out the issue as above to Brian Goetz at JAX in Mainz where he had presented said draft. My proudest professional moment.

Take away: If you deal with keyboard magic and ergonomics, spend a couple minutes to check your assumptions behind your defaults in the other big keyboard layouts.


this. i'm on the swiss german keyboard layout. backticks are hard to do as a keyboard shortcut. they barely work as a character (e.g. for markdown formatting) but with a bit of pracitce that _does_ work.

try getting default vim bindings to work on a swiss german keyboard... i eventually gave up.


I'm in the same boat as you and after 15 years of coding I finally switched to the US layout 3 weeks ago. Got a Wooting 60HE and installed the EuroKey layout and so far I'm super happy about the switch and many default shortcuts make a lot more sense (e.g. no more acrobatics needed for ctrl+b+[ to enter tmux copy mode).

The first few days are a little rough to unlearn all the muscle memory but I found this neat site to practice typing with your own public gists: https://www.codetyper.io/


I've long used the US international layout with Alt-Graph deadkeys. (For the full experience, you can perhaps buy an ANSI format keyboard from the Netherlands?)

It takes some practice getting AltGr+y as ü and AltGr+w as ä and AltGr+p as ö into your muscle memory, let alone AltGr+circumflex instead of just circumflex to get the dead key (raison d'être requires AltGr+Shift+6 to type properly), but I've found it's otherwise a remarkably workable tradeoff.


I don't know what QWERTZ is but as a life long Swedish Linux user I can tell you that backtick is a terrible key to use as a keyboard shortcut. It's often relatively hard to find and hard to generate.


Wait, it is not simply "key in the top left" regardless of layout? That is how it works in any Linux desktop at least.


No. On German and Swiss layouts, that key is a dead key: it doesn't type anything by itself when you press it. It's meant to combine with another subsequent keypress in order to yield a whole glyph with a diacritic as in, e.g., backtick followed by "e" giving "è."

It's been a while since I've been at a proper QWERTZ layout aus dem Sprachgebiet over a US QWERTY keyboard, but my memory is that the dead keys have odd behaviors when you try to incorporate them into shortcuts.


What key are you referring to, the backtick key, or the Alt+[KEY] used by the app?


The alt+[key]. On linux it is alt+tab (between different apps) and alt+[key physically above tab] (between windows of the same app), regardless of keyboard layout. Moving the shortcut away from there or even to convoluted things like "Alt+Shift+´+Space" seems very strange, hence the the question.


Compared to KDE, I have a feeling that both Windows and macOS have pretty primitive usability options. Windows got some improvements in this area only recently, but I think macOS is still behind.

When I'm using macOS, I can't stand the GUI without these tools:

Rectangle: https://rectangleapp.com/

Easy Move+Resize: https://github.com/dmarcotte/easy-move-resize

They move the macOS desktop usability near the place where KDE was in the late 2000's.


Two things that KDE did/does better than Windows.

The way thumbnails work, the whole KParts and D-Bus tooling infrastructure, versus COM that has hardly improved in any meaningfull way during the last 30 years.

However market share and being better technically aren't directly related.


Neither KParts nor D-Bus are better than COM though.

KParts is just some way to expose a Qt widget, at best comparable to something like ActiveX (a very specific use of COM, not the entirety of what you can do with COM), but even the functionality it exposes is limited. Hell, it might be closer to OLE 1 than even OLE 2. It feels like it was made by someone looking at a specific use of COM/OLE2 in some popular Windows application back in the 90s and decided that that's everything the tech is all about and can do - so you could probably make something like custom WordPad controls with it (though from the docs i don't see any way to store instance-specific data, so you probably can't even get OLE-like functionality) but you couldn't make something like, say, Visual Basic / VBA. Of course being written for Qt it is also inherently limited to be usable only in terms of C++ and with specific Qt versions, which certainly makes is less generic than COM.

D-Bus is a bit closer to COM in that like COM it can be used to have a centralized registry of methods exposed via interfaces in objects to call, but is still also more limited in that it is only meant for passing messages across processes - you can't, e.g., use it to create a "decoder" object with a method you call from several threads in which you give it two memory pointers, one with a buffer of encoded bytes and another to place the decoded bytes into. The closest with D-Bus would be to communicate details for the decoding (perhaps via other IPC methods like shared memory, but that'd be outside of D-Bus itself), though with little control over how it is done. Also FWIW D-Bus has nothing KDE-specific in it (if anything it came out of the GNOME world).

COM might have seen little improvement since Windows 95 but even COM in Windows 95 provides more functionality than what KParts or D-Bus do in modern Linux, so i wouldn't call the latter more technically advanced at all. The only benefit they have is being designed a few years after COM so they didn't had the constraint of having to run in systems with 8MB of RAM.


In what concerns developer tooling, 100% definitely better than COM.

"Modern" COM tooling, is only modern in that the MIDL language is now at version 3.0, everything else is as modern as using Visual C++ in Windows 95 with either MFC or ATL 1.0.

Which is kind of unbeliveble, given how much COM gets pushed everywhere on Windows, that WinDev likes so much their primitive tooling, even Borland provides a much better COM developer experience.

The only time in COM's lifetime that they actually improved the developer experience, with C++/CX, it was killed by an internal riot, and replaced by a bad joke reminiscient of the same ATL experience WinDev loves so much.


I won't argue that COM tooling is bad - and really even the tech itself is overall more complicated than it should be, but at the end of the day between a tech with awful tooling that can do something you need and a tech with good tooling that is incapable of doing something you need, i'd still call the former overall better from a technical perspective (even if in practice i'd rather use neither).


Well, I have C, JavaScript, PHP, Go in the same bucket of "awful tooling that can do something you need...", which doesn't make COM any better.

Windows developers basically have no option, as since Windows Vista, most of native APIS are no longer classical Win32 C APIs, rather COM, and on top, we have to write .NET bindings by hand, because why would WinDev care about other programming stacks developed by their employer anyway.


> Compared to KDE, I have a feeling that both Windows and macOS have pretty primitive usability options.

I think that comparison would be with most window managers on Linux (and most other Unices) :-P. I have that exact same functionality (Alt+` to switch between same-app windows) in Window Maker and while i'm not using that often to miss it in other systems, one functionality i really miss often when using Windows is the ability to "roll up/down" windows with the mouse wheel (something that AFAIK most stacking window managers can do on Linux) and being able to "select" windows by dragging a rectangle around them and moving them around together as a unit or moving them across workspaces/virtual desktops.


For those mentioning autohotkey, this is what I use when on windows do get the same functionality:

  CycleCurrentApplication() { ; {{{1
      curID := WinGetID("A")
  
      ActiveClass := WinGetClass("A")
   ActiveExe := WinGetProcessName("A")
      oList := WinGetList("ahk_exe " ActiveExe " ahk_class " ActiveClass,,,)
      Loop oList.Length
      {
          index := oList.Length - A_Index + 1
          State := WinGetMinMax("ahk_id " oList[index])
          nextID := WinGetID("ahk_id " oList[index])
  
          if (State != -1) ; if window not minimised
          {
              WinID := oList[index]
              break
          }
      }
      WinActivate("ahk_id " WinID)
  } ; }}}1
the 'activeclass' AND 'activeexe' are there to handle cases like explorer. I primarily use this for multiple instances of firefox (although I've got specific binds to jump directly to non-media and media firefox)


Cool project. Even after the improvements in Windows 10 and 11, windowing could do with some work, which spurs projects like this (ironic given the OS is called Windows).

I hardly use Alt-Tab. I use Windows-Tab instead, and in the resulting Task View, mouse over to the window I need.

I've bound that keyboard shortcut as well as Ctrl-Windows-Left and Ctrl-Windows-Right (switch virtual desktop left or right) each to a different mouse button which makes things so much more productive. I've got a wireless Logitech G502x with about seven buttons on it, best mouse investment ever.

After RDPing to my home workstation on a MacBook I realised how much my productivity collapsed if I don't have access to that mouse.


For years I used a freeware utility called VistaSwitcher for this. Could similarly customize the hotkey and also allowed changing the Alt-Tab menu to be a quicker-to-parse text based list instead of the giant thumbnails Windows uses by default.

The Mac way of cycling within the same program is very useful and one of the things I like borrowing when using Windows, as accidentally Alt-Tab'ing to a different program when there are multiple windows open from one source (eg: text editor) becomes annoying.


Stockholm syndrome much? Why would the windows that I am multi-tasking on just coveniently belong to the same app for me to use this shortcut?


It can be more efficient when combining both Alt-Tab and Alt-` - if you have several windows open in multiple different apps, it's easier to first Alt-Tab to the app you want and then Alt-` to the window you want rather than Alt-Tabbing through like 20 individual windows.

That being said, I don't really strongly prefer one system over the other; the main cost is in switching between them and using the wrong shortcut for a while (more a problem on the OS with 2 shortcuts, i.e. Linux). This would be helpful to avoid that, but so would configuring whatever Linux windows manager I'm using to only use Alt-Tab.


I am not sure but having used AutoHotKey recently for a few qol things, it feels like AHK would be able to do this too.


It is able to do this, and it being Ahk, it's also more customizable


Anyone has a working AutoHotKey script for same program window switch on Windows? The same way how Ubuntu Unity works.

Last one I used didn't work with File Explorer (since it is the same program as the Desktop), and I couldn't make it work, and it was more annoying than useful at the end.


I've posted a function which should handle this https://news.ycombinator.com/item?id=41288792 and you can bind it to whatever key you like.

I remember vaguely having the same explorer-window issue as you mentioned, which is why I use both the Active Class and Active Exe of the current window.


In Gnome (I think?) I am able to scroll over an application icon to switch between same application windows. Is this possible in Win11?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: