AltTab brings the power of Windows alt-tab to macOS
lwouis / alt-tab-macos Goto Github PK
View Code? Open in Web Editor NEWWindows alt-tab on macOS
Home Page: https://alt-tab-macos.netlify.app
License: GNU General Public License v3.0
Windows alt-tab on macOS
Home Page: https://alt-tab-macos.netlify.app
License: GNU General Public License v3.0
AltTab brings the power of Windows alt-tab to macOS
This is OSS, so for the icon creation process, I don't want to decide everything. However, I would like to share some important considerations:
Asks:
Discussion:
I looked at /System/Library/CoreServices/Dock.app
, and I like the abstract icon:
Also the Mission Control icon (can't find where it is again today):
I think something similar may be a good idea: an abstract list of windows, and maybe some arrow showing a switch from one to another.
Also as inspiration, here is what similar apps have gone with:
Opening this window in chrome:
https://www.youtube.com/watch?v=EQwOKQKv4Pg
It seems the title of the window doesn't match between the 2 OS APIs:
AXUIElementCopyAttributeValue
: "final fantasy ⁷ ~ lofi hip hop mix - YouTube - Audio playing - Google Chrome - Home"CGWindowListCopyWindowInfo
: "final fantasy ⁷ ~ lofi hip hop mix - YouTube 🔊"We could implement a workaround specific to youtube. It would be nicer of course to find a general approach.
Follow-up to issue #12. Line is not showing
Currently windows from other spaces, including fullscreen'd windows that are in their own space, are not displayed in the thumbnails
Switching works fine when I open it from terminal /Applications/alt-tab-macos.app/Contents/MacOS/alt-tab-macos
but it doesn't show the switching popup when I open the app from Finder or open /Applications/alt-tab-macos.app/
It runs in status bar and binds to ctlr + tab shortcut because I can not longer switch between Firefox tabs but nothing happens. I have given the app Accessibility permission.
Tested on latest macOS Catalina version.
Hello, the app is a great idea, always suffer this problem.
I think the title is self descriptive, could it work with older versions, for example (I'm using)
Sierra 10.12.6 (Can't update to new versions).
When installing the latest version on my workstation, the app does not start.
By CLI, it seems to be an issue with the config file parsing.
"Error loading preferences from JSON file on disk" "Optional contained nil"
➜ ~ cat ~/Library/Preferences/alt-tab-macos.json
{
"windowDisplayDelay" : "200",
"cellPadding" : "6",
"thumbnailMaxHeight" : "0",
"metaModifierFlag" : "262144",
"maxScreenUsage" : "0.8",
"cellBorderWidth" : "2",
"thumbnailMaxWidth" : "0",
"highlightColor" : "white",
"maxThumbnailsPerRow" : "4",
"fontHeight" : "15",
"thumbnailQuality" : "4",
"interItemPadding" : "4",
"metaKey" : "59",
"tabKey" : "48",
"iconSize" : "32",
"windowPadding" : "20"
}%
➜ ~ cat ~/Library/Preferences/alt-tab-macos-defaults.json
{
"windowDisplayDelay" : "200",
"cellPadding" : "6",
"thumbnailMaxHeight" : "0",
"metaModifierFlag" : "262144",
"maxScreenUsage" : "0.8",
"cellBorderWidth" : "2",
"thumbnailMaxWidth" : "0",
"highlightColor" : "white",
"maxThumbnailsPerRow" : "4",
"fontHeight" : "15",
"thumbnailQuality" : "4",
"interItemPadding" : "4",
"metaKey" : "59",
"tabKey" : "48",
"iconSize" : "32",
"windowPadding" : "20"
}%
➜ ~ sw_vers
ProductName: Mac OS X
ProductVersion: 10.14.6
BuildVersion: 18G103
25 › <key>CFBundleVersion</key>
26 › <string>1.5.1</string>
When filing bug reports, it's useful to be able to send the version of the software that the user is running. Currently, as far as I can tell, there's no way to see this. When there's a config panel (#8) it could be shown there. It would also be a good idea to put the version in the downloaded archive name.
Currently, activating alt-tab will steal focus. The user should be able to interact with alt-tab's UI without having the previous window lose its focus. This is done correctly by HyperSwitch
If you switch to an app via the dock icon, all windows of that app become ‘recently used’ in the alt-tab menu.
The documentation for the kCGWindowListOptionOnScreenOnly constant says:
List all windows that are currently onscreen. Windows are returned in order from front to back. When retrieving a list with this option, the relativeToWindow parameter should be set to kCGNullWindowID.
Original author on this HackerNews thread
It is not possible to display thumbnails for minimized windows, but we could display a message instead.
Listing the minimized windows would be done by removing .optionOnScreenOnly
in CGWindowListCopyWindowInfo([.excludeDesktopElements], kCGNullWindowID)
Allow arrow keys to move backward and forward between open windows when switcher is active. Right now, the only way to move backward is to shift tab, or to select previous window with mouse.
Add quick actions on thumbnails, similar to what WindowSwitcher is doing:
I think only these are actually useful:
In a first phase, keyboard only, then maybe some visual buttons can be added.
More details in this video, especially the minimize behaviour which shows limitation of the Mac API (can't get thumbnail of a minimized window)
Wouldn't CMD+TAB be better for this app instead of another shortcut that may conflict with other apps?
The .app
is unsigned currently. When the user opens the app for the first time, they get a scary prompt, and must jump through hoops to allow the app to run:
Getting an apple certificate and signing the app would remove that friction.
Here is a tutorial: https://successfulsoftware.net/2012/08/30/how-to-sign-your-mac-os-x-app-for-gatekeeper/
An issue is that this means buying a 100$/year apple dev account. Beyond the money, it makes this less of an open-source project as i would need my personal paid account to sign. Forks would need their own accounts to sign. I don't think there is any way around this though. This is an Apple ecosystem limitation.
I couldn't find an issue on this, so sorry if it's been asked before.
Why isn't the keybind alt+tab, instead of ctrl+tab?
Any chance this could be distributed on the Mac App Store as well?
I'm working with an 3-display setup, sometimes it happens that I select the wrong window. when I open the switcher again the overlay is on the monitor with the opened app, even if my mouse is on an other display.
see also #8
After installing alt-tab (now I've uninstalled it, didnt help) my menu now is disappearing. I have a second monitor hooked up and when I use/open something in the second screen, my menu bar on my mac goes white (https://imgur.com/a/eZpGknW), what has happend, would like to fix this asap
During normal usage, sometimes the app will stop responding to global shortcuts.
I recorded an instance of this where I saw these logs:
"event" 11
"event" 12
"meta down"
"unexpected 1" [2807: 1]
"unexpected 2" [<AXUIElement 0x7ff860f95c40> {pid=2807}]
"event" 12
"meta up"
"event" 12
"event" 12
"event" 11
"event" 12
"meta down"
"unexpected 1" [2807: 1, 13366: 0]
"unexpected 2" [<AXUIElement 0x7ff860f8e3b0> {pid=2807}]
"event" 10
"event" 4294967294
These logs come from this update I made locally in the source code:
func computeOpenWindows() {
openWindows.removeAll()
// we rely on the fact that CG and AX APIs arrays follow the same order to match objects from both APIs
var pidAndCurrentIndex: [pid_t: Int] = [:]
for cgWindow in cgWindows() {
let cgId = cgWindow[kCGWindowNumber] as! CGWindowID
let cgTitle = String(cgWindow[kCGWindowName] as! NSString)
let cgOwnerPid = cgWindow[kCGWindowOwnerPID] as! pid_t
let i = pidAndCurrentIndex.index(forKey: cgOwnerPid)
pidAndCurrentIndex[cgOwnerPid] = (i == nil ? 0 : pidAndCurrentIndex[i!].value + 1)
let axWindow = axWindows(cgOwnerPid)
if axWindow.count > pidAndCurrentIndex[cgOwnerPid]! {
openWindows.append(OpenWindow(target: axWindow[pidAndCurrentIndex[cgOwnerPid]!], ownerPid: cgOwnerPid, cgId: cgId, cgTitle: cgTitle))
} else {
debugPrint("unexpected 1", pidAndCurrentIndex)
debugPrint("unexpected 2", axWindow)
}
}
}
Note that the app isn't crashed. It is ignoring global shortcuts and stdout isn't producing new values
First of all, thank you for this great app, I really like it!
However, on my 2016 MacBook Pro, getting the UI to show up feels very sluggish, even though I set the delay to 0ms. After investigating the code a bit and running some tests, it seems like recomputing the thumbnails every time the UI shows up is quite expensive.
In my testing I had around 10 windows open and the following lines of code resulted in around 200ms of time:
alt-tab-macos/alt-tab-macos/ui/Application.swift
Lines 151 to 154 in 7ff17b5
OpenWindow
. A few suggestions on how this could be fixed:
Hey,
just recognized the "Download the latest release Link" is currently not working.
It would be great if you git fix it :)
Thanks & best regards,
Matt
Some apps (like Slack) seem to handle window titles differently.
In WindowManager.swift
's axWindows
function, windows get filtered by whether they have a title or not. Slack for example does have a title (passes the check in Application.swift
's computeOpenWindows
) but it returns nil
here. My guess is we should remove the title validation in axWindows
.
Press alt-shift-tab before pressing alt-tab. It doesn't work
It is helpful to identify which version of the app one is running. This can be done by simply adding a new text line in the menubar menu.
Version is generated during CI build on master. I bash script could replace some placeholder in the code before the xcodebuild
happens.
It would be great if we could select an app/window by mousing over it, just like you can do with CMD+Tab by mousing over the app icon.
Thanks!
I really like that you made this available to the proprietary abandonware (but otherwise mostly working) Hyperswitch. Could you provide a way to allow users to make a donation?
Let users customize some defaults values. In order of usefulness:
Application.swift
To illustrate, this is how HyperSwitch does it:
Not sure, how it is now in Windows 10, but my fingers remember that when looping through windows hitting Esc cancels it, which is pretty useful when you've changed you mind or satisfied with a window preview. Of course Ctr-Shift-Tab is an option to go back but not that useful.
Without this, wide but low-height thumbnails take an extreme amount of space
Could you allow a way to modify https://github.com/lwouis/alt-tab-macos/blob/master/alt-tab-macos/resources/preferences.json within a text editor, say in ~/Application Support/Library/AltTab/preferences.json? That would the user to change the keybind.
In Hyperdock (combined with Karabiner Elements / Hammerspoon) I use Cmd+Space to "alt tab" and Meta+Cmd+Space to "alt tab within application". It allows to keep Ctrl+Tab intact, as it is also used in e.g. Firefox, iTerm, ...
In this example, I would like to change
"metaKey": 59,
to
"metaKey": 55,
as per [1]
[1] https://eastmanreference.com/complete-list-of-applescript-key-codes
If i have two displays setup like like
DIsplay 1: Chrome1
Display 2: Spotify Chrome2
If i control-tab from Spotify to Chrome1 then Chrome2 is focussed instead. It doesn't happen if I swap Chrome1 and Chrome2 so I have a feeling it depends on the order of the two windows being opened
Right now the UI shows a snapshot of windows at the time the shortcut is pressed. This has pros: the UI is stable and not changing on the user, but also cons: the UI doesn't reflect the current state of windows.
It's a tradeoff between stability and change. I would love feedback from other people about this. Making it should be a preference?
App crashed with following log in AppCode:
"event" 12
"event" 12
"meta down"
"event" 10
"meta+tab down"
"event" 11
"event" 12
"meta up"
Fatal error: Unexpectedly found nil while unwrapping an Optional value
"event" 12
"meta down"
Process finished with exit code 132 (interrupted by signal 4: SIGILL)
Rounded corners would help the switcher blend into the OS.
Current UI to set user preferences is raw:
Goal 1
Fewer options and better validation. In order of priority:
Here is HyperSwitch more refined UI as reference:
Goal 2
Better documentation. Replace current text with shorter explanations, and add either a hover tooltip or some other variation of more-info-on-demand UI, so that users who found the short text unclear can get more explanations. We can think about adding illustrations/images/videos here too to help get the point across.
Goal 3
Make categories like dimensions, keyboard, performance, etc. This can be tabs as is traditional on macOS, or any other approach.
Goal 4
Make all preferences live. Currently some of them are live, and some require a restart to apply. An easy fix would be to kill and recreate the main window on preferences change. Another brute-force approach would be to add a "restart the app" button at the bottom.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.