lwouis / alt-tab-macos

Windows alt-tab on macOS
https://alt-tab-macos.netlify.app
GNU General Public License v3.0
10.58k stars 322 forks source link

Keyboard shortcuts sometimes stop working (Secure Input) #157

Closed stevemartina-salesforce closed 4 years ago

stevemartina-salesforce commented 4 years ago

v2.3.2 often doesn't fire - Alt-Tab invokes the standard MacOS switcher, except releasing the keys doesn't dismiss the dialog. I need to click on an icon or press Enter to dismiss. Alt keys is Cmd, Tab is 48, theme is MacOS. MacOS Mojave 10.14.6

Normally restarting Alt-Tab does the trick, but lately it doesn't change anything.

lwouis commented 4 years ago

@joeberlin123 that's very interesting! If DeepL also stops responding to global shortcuts when AltTab does, it seems to indicate that the issue is not in AltTab code, but with your system. @mfn Could you try installing the DeepL mac app as well? It's small, and you hit command-c twice to trigger it, after selecting text anywhere. Next time AltTab stops working, you can try hitting that other shortcut, and seeing if it also fails on your machine like @joeberlin123. That would be a very interesting data point!

Kentzo commented 4 years ago

@lwouis I downloaded and took a look inside the DeepL app (DeepL Helper to be specific). It's written in Swift and disassembly is quite cryptic, I was only able to deduce that it uses the CGEventCreateKeyboardEvent and CGEventPost functions to inject ⌘C / ⌘V.

lwouis commented 4 years ago

@Kentzo I would imagine that they use this to resend the shortcut after they have intercepted it? Not sure why they don't simply return the original event. Do you know if they use CGEventTapCreate to listen to shortcuts like AltTab?

Kentzo commented 4 years ago

I didn't find any uses of CGEventTapCreate.

kungpaogao commented 4 years ago

If the issue is gone for everyone, then I'll happily close this ticket of course!

I haven't been running into any issues for a while now. For reference, I'm on macOS 10.15.5, latest AltTab, and not really running anything else related to keyboard shortcuts. Thanks for the hard work!

MatthewScholefield commented 4 years ago

Hi, I'm having the same issue (alt+tab triggers mac switcher, icon still in tray, manually clicking shows switcher but doesn't fix problem). I tried updating from 4.0.0 to 4.2.0 and it didn't fix the problem. I also tried installing DeepL and can confirm cmd+c,cmd+c does not work there either. I'm going to try rebooting and see if that helps.

I'm on macOS 10.15.5.

Edit: Restarting fixed it for me

joeberlin123 commented 4 years ago

Hi, I'm having the same issue (alt+tab triggers mac switcher, icon still in tray, manually clicking shows switcher but doesn't fix problem). I tried updating from 4.0.0 to 4.2.0 and it didn't fix the problem. I also tried installing DeepL and can confirm cmd+c,cmd+c does not work there either. I'm going to try rebooting and see if that helps.

Additional info: Other apps with global shortcuts like Alfred work - even if AltTab and DeepL do not work. Are there possibly different variants to listen to global shortcuts?

lwouis commented 4 years ago

Yes there are multiple APIs to listen to global shortcuts. I think 3:

It is possible that the API used by AltTab has the issue, and not other APIs. That being said, there is no easy way to migrate to another API:

lwouis commented 4 years ago

I filmed a video where I explain the overall situation with keyboard events on macOS. I share all my knowledge on the topics, highlight issues specific to Catalina, investigate the origin of the bug happening in this ticket, etc.

Please have a look at it, and share feedback if you have some 👍

@Kentzo @koekeishiya I think you guys may find this overview interesting!

Links mentioned in the video:

koekeishiya commented 4 years ago

I don’t have time to go into details, but you could likely use the same set of APIs as the Dock uses to listen for cmd+tab; CGSRegisterKeyForConnetion/CGSStealKey.. etc. IIRC.

koekeishiya commented 4 years ago

One final thought; the reason why this happens is likely because Secure Keyboard Input is enabled by some running application such as a password manager, focusing a nssecuretextfield or similar, and it is not propely disabled again by said app. This is a security mechanism of macOS built into the Quartz Event Tap API.

lwouis commented 4 years ago

Omg @koekeishiya you're brilliant! I should have thought about this explanation as I investigated this issue in the past!

I just tested it, and indeed, on a system password field (I went to System Preferences > Security & Privacy, and clicked the lock icon at the bottom left to test it easily), AltTab and DeepL are indeed not capturing the keyboard shortcuts, whereas Alfred is!

This explains everything, and why it's never happening on my computer!

Now moving forwards has issues:

We could go the Alfred route, and use an API that ignores secure field. I imagine they use the Carbon API? But then how are they able to absorb the keys from the shortcut? Not sure. But anyway, there is a moral objection to that. I know that's it's Apple faults here, and that the Carbon API should be updated to also not receive keyboard inputs when password field are focused, but I still find it wrong to circumvent this protection by using the Carbon API.

That being said, if it's up to each app (I thought it was automatic from using specific NSView objects) to release this secure keyboard input, then we can have these apps break AltTab from their bad programming. It's quite a crazy situation that an app may not release some secure mode, and break many other apps on the system...

Not sure if we should:

BetterTouchTool, which is one of the most sophisticated app in that space, seems to switch to the Carbon API, by default, when Secure Input is activated by an app:

image

lwouis commented 4 years ago

I don’t have time to go into details, but you could likely use the same set of APIs as the Dock uses to listen for cmd+tab; CGSRegisterKeyForConnetion/CGSStealKey.. etc. IIRC.

I couldn't find these APIs, but looking at symbols from the SDKs, I think you may have meant these APIs?

_CPSRegisterForKey / _CPSRegisterForKeyOnConnection
_CPSStealKeyFocus / _CPSStealKeyFocusOnConnection

In any case, I think if we are willing to read password fields, we can simply use the public Carbon API to do so. At least it's commonly used. I couldn't find a single project on github using the above APIs 😅

lwouis commented 4 years ago

@stevemartina-salesforce @joeberlin123 @mfn @kungpaogao @kingfisher77 next time you run into the issue, could you please type this in the Terminal?

ioreg -l -w 0 | grep SecureInput | awk 'BEGIN {FS="[^a-zA-Z0-9]+"} {print $8}' | uniq | xargs -n 1 ps aux

It should show you which app is activating Secure Input, thus preventing AltTab and other global-shortcut apps to work. This person explains that its their company's VPN that activates it as long as it's open. Pretty bad situation.

These scenarios make me swing towards moving to Carbon API...

mfn commented 4 years ago

Omg. This is such an incredible revelation!

I yet have to collect evidence from when it unexpectedly happens, but I was eager to try this out and can confirm this:

image

Now, not likely to AltTab away from that input but the same applies when I edit a 1Password entry (which shows password fields covered, without having focus on the specific password field). And I would say it's not unlikely to edit 1password but then switch forth/back between other apps during this.

I'll make sure to run until false; do ioreg -l -w 0 | grep SecureInput | awk 'BEGIN {FS="[^a-zA-Z0-9]+"} {print $8}' | uniq | xargs -n 1 ps aux; sleep 1; done in a background terminal do capture the real offenders when it happens the next time outside lab conditions :)

lwouis commented 4 years ago

Apple really dropped the ball on this system. It is a clear necessity to have a similar mechanism in an OS, but their UX is not good. They could for example have some UI indicator somewhere showing you that Secure Input is activated. Maybe in the menubar like they do for Location, maybe a dedicated popover. Anything showing the user that an app has activated this global flag, and that all accessibility software using the keyboard is now unable to function.

Another approach, I think better, would be to simply remove this global flag API, and rely on using NSSecureTextField which has that flag switching internalized. This way you guarantee no app forgets to turn it off, and for the user there is no need to communicate further as they can understand that password fields are protected.

But again, what's even the point of such feature if they forgot to check that flag when using their Carbon API, and you can still keylog using it? Apple what are you doing...

koekeishiya commented 4 years ago

I have actually managed to tap into key events that also bypass Secure Keyboard Input, and it does not require any entitlements or elevated permissions at all (not even accessibility access or whatever it is that cgeventtap used.)

With this method I actually have access to more information than what is provided through Quartz events as well.

I’m sure there are other people out there that are aware of this, but I am not so sure if I should open source this.

TLDR; Input in macOS is extremely insecure and so called Secure Keyboard Input is a complete joke.

Edit: Turns out it does need access to the accessibility API; I had a shell session running that was already authorized.

lwouis commented 4 years ago

@koekeishiya do you mean something like this? To bypass user-land security measures, you would need to run that as root though. Is your method working without root? Is it a low-level IOKit style method?

Currently here are the options I'm envisioning for AltTab being blocked when Secure Input is enabled by another app silently:

Do you think your technique would be a good approach for AltTab, or should I pick one of those options above?

koekeishiya commented 4 years ago

Works without root and I am not using IOKit

Sent from my iPhone

On 16 Jul 2020, at 15:22, lwouis notifications@github.com wrote:



@koekeishiyahttps://github.com/koekeishiya do you mean something like thishttps://code.google.com/archive/p/logkext/? To bypass user-land security measures, you would need to run that as root though. Is your method working without root? Is it a low-level IOKit style method?

Currently here are the options I'm envisioning for AltTab being blocked when Secure Input is enabled by another app silently:

Do you think your technique would be a good approach for AltTab, or should I pick one of those options above?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/lwouis/alt-tab-macos/issues/157#issuecomment-659407772, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABPDZV5GLAU2ZIYDCU7QQ2TR335IRANCNFSM4KS6U36Q.

koekeishiya commented 4 years ago

Regarding what’s best for alt-tab, I would go with the private APIs used by the Carbon hotkey framework (the ones you mentioned above) if they are able to give you the functionality you require.

I was in the process of writing a tool similar to skhd and wanted it to not get blocked by Secure Keyboard Input this time around, and so I will probably finish that using the technique I discovered before I publish anything.

Sent from my iPhone

On 16 Jul 2020, at 15:35, Åsmund Vikane aasvi93@hotmail.com wrote:

 Works without root and I am not using IOKit

Sent from my iPhone

On 16 Jul 2020, at 15:22, lwouis notifications@github.com wrote:



@koekeishiyahttps://github.com/koekeishiya do you mean something like thishttps://code.google.com/archive/p/logkext/? To bypass user-land security measures, you would need to run that as root though. Is your method working without root? Is it a low-level IOKit style method?

Currently here are the options I'm envisioning for AltTab being blocked when Secure Input is enabled by another app silently:

Do you think your technique would be a good approach for AltTab, or should I pick one of those options above?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/lwouis/alt-tab-macos/issues/157#issuecomment-659407772, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABPDZV5GLAU2ZIYDCU7QQ2TR335IRANCNFSM4KS6U36Q.

nathanshelly commented 4 years ago

to add another example of a window/app switching app handling secure input Contexts (at the time of this writing their site is down for maintenance, I assume this is only temporary 🤷 ) puts a little error sign in the menu bar with helpful text when clicked on:

image
lwouis commented 4 years ago

I will probably finish that using the technique I discovered before I publish anything.

You got me so curious now! I can't wait to see how this works!

lwouis commented 4 years ago

@nathanshelly oh that's nice! Even listing which app may be responsible.

That being said, if you look at the experience of Alfred, it just works. You can be editing a password, hit the shortcut, and Alfred shows up. They also handle shortcuts and modifiers-only shortcuts, indicating that they are not using either Carbon or Quartz API. I tried to retro-engineer their app but couldn't find which API they use.

Given that security is not the topic here since Secure Input is easy to defeat, I think I would rather go in the direction of best UX, whichever tech is behind it. AltTab is already way too low-level to go in the Mac AppStore anyway, so why not double down on tricks to get the best UX

mfn commented 4 years ago

I mean, this thing with the secure input… have your cursor in a firefox webpage password field and AltTab doesn't respond until you leave it (you'll get the default window manager though). Oh my

just-Bri commented 4 years ago

Just wanted to say thanks for the quick reply, @lwouis!

My issue with the Outlook desktop stopped after I quit Outlook and opened it again. Now it works fine so I cannot reproduce it. I use alt-tab as my shortcut by the way.

lwouis commented 4 years ago

@koekeishiya Here are the results of my efforts so far:

API supports modifiers-only shortcuts event propagation works through Secure Input
CGEvent.tapCreate Yes Can propagate or not No
RegisterEventHotKey No Can't propagate Yes
NSEvent.addGlobalMonitorForEvents Yes Can't propagate ?
CGSSetHotModifierWithExclusion + CGSSetHotKeyWithExclusion Yes Can't propagate Yes
IOHID Yes ? No

Each of these 5 API fails to deliver a feature I need. I feel at a dead-end. Could you please consider sharing your new technique? You mentioned you will open-source it at some point. If you do it now, I would be able to integrate it into AltTab and have all users finally enjoy a flawless shortcut experience.

koekeishiya commented 4 years ago

@lwouis It's not really robust enough for use in real software; I haven't spent more time trying to resolve the issue yet. I'll send you an email with what I have for now and you can feel free to experiment with it if you'd like.

mfn commented 4 years ago

Right now AltTab (and HyperSwitch as well!) refuse to listen to CMD-Tab. Totally. Even a restart does nothing (both apps).

Console:

default 22:54:59.554894+0200    tccd    -[TCCDAccessIdentity staticCode]: static code for: identifier com.lwouis.alt-tab-macos, type: 0: 0x7f9cf74195d0 at /Users/neo/Applications/AltTab.app
default 22:55:10.882852+0200    AltTab  keyboardHandler1: true, 12, 1048840
default 22:55:10.882900+0200    AltTab  keyboardHandler2: 1048840, 55
default 22:55:10.882937+0200    AltTab  keyboardHandler3: false, false
default 22:55:10.883003+0200    AltTab  keyboardHandler6: true
default 22:55:12.226674+0200    AltTab  keyboardHandler1: true, 12, 256
default 22:55:12.226713+0200    AltTab  keyboardHandler2: 256, 55
default 22:55:12.226777+0200    AltTab  actionHandler1: holdShortcut, false
default 22:55:12.226794+0200    AltTab  actionHandler2: false
default 22:55:12.226814+0200    AltTab  keyboardHandler3: false, false
default 22:55:12.226850+0200    AltTab  keyboardHandler6: true
default 22:55:12.316960+0200    AltTab  keyboardHandler1: true, 12, 0
default 22:55:12.317004+0200    AltTab  keyboardHandler2: 0, 0
default 22:55:12.317032+0200    AltTab  #Error Unexpected key code 0 for the FlagsChanged event
default 22:55:12.317049+0200    AltTab  keyboardHandler3: false, false
default 22:55:12.317087+0200    AltTab  keyboardHandler6: true
default 22:55:22.883115+0200    AltTab  keyboardHandler1: true, 12, 1048840
default 22:55:22.883171+0200    AltTab  keyboardHandler2: 1048840, 55
default 22:55:22.883212+0200    AltTab  keyboardHandler3: false, false
default 22:55:22.883263+0200    AltTab  keyboardHandler6: true
default 22:55:24.090773+0200    AltTab  keyboardHandler1: true, 12, 256
default 22:55:24.090816+0200    AltTab  keyboardHandler2: 256, 55
default 22:55:24.090888+0200    AltTab  actionHandler1: holdShortcut, false
default 22:55:24.090908+0200    AltTab  actionHandler2: false
default 22:55:24.090928+0200    AltTab  keyboardHandler3: false, false
default 22:55:24.090969+0200    AltTab  keyboardHandler6: true
default 22:55:27.714647+0200    AltTab  keyboardHandler1: true, 12, 1048840
default 22:55:27.714684+0200    AltTab  keyboardHandler2: 1048840, 55
default 22:55:27.714715+0200    AltTab  keyboardHandler3: false, false
default 22:55:27.714759+0200    AltTab  keyboardHandler6: true
default 22:55:28.370693+0200    AltTab  keyboardHandler1: true, 12, 256
default 22:55:28.370734+0200    AltTab  keyboardHandler2: 256, 55
default 22:55:28.370801+0200    AltTab  actionHandler1: holdShortcut, false
default 22:55:28.370820+0200    AltTab  actionHandler2: false
default 22:55:28.370837+0200    AltTab  keyboardHandler3: false, false
default 22:55:28.370883+0200    AltTab  keyboardHandler6: true
default 22:55:33.275563+0200    AltTab  keyboardHandler1: true, 12, 1048840
default 22:55:33.275625+0200    AltTab  keyboardHandler2: 1048840, 55
default 22:55:33.275665+0200    AltTab  keyboardHandler3: false, false
default 22:55:33.275716+0200    AltTab  keyboardHandler6: true
default 22:55:34.051395+0200    AltTab  keyboardHandler1: true, 12, 256
default 22:55:34.051455+0200    AltTab  keyboardHandler2: 256, 55
default 22:55:34.051522+0200    AltTab  actionHandler1: holdShortcut, false
default 22:55:34.051537+0200    AltTab  actionHandler2: false
default 22:55:34.051554+0200    AltTab  keyboardHandler3: false, false
default 22:55:34.051604+0200    AltTab  keyboardHandler6: true
default 22:55:34.914887+0200    AltTab  keyboardHandler1: true, 12, 1048840
default 22:55:34.914930+0200    AltTab  keyboardHandler2: 1048840, 55
default 22:55:34.914962+0200    AltTab  keyboardHandler3: false, false
default 22:55:34.915015+0200    AltTab  keyboardHandler6: true
default 22:55:35.034754+0200    AltTab  keyboardHandler1: true, 12, 256
default 22:55:35.034792+0200    AltTab  keyboardHandler2: 256, 55
default 22:55:35.034857+0200    AltTab  actionHandler1: holdShortcut, false
default 22:55:35.034872+0200    AltTab  actionHandler2: false
default 22:55:35.034888+0200    AltTab  keyboardHandler3: false, false
default 22:55:35.034926+0200    AltTab  keyboardHandler6: true
default 22:55:43.740091+0200    AltTab  keyboardHandler1: true, 12, 1048840
default 22:55:43.740196+0200    AltTab  keyboardHandler2: 1048840, 55
default 22:55:43.740288+0200    AltTab  keyboardHandler3: false, false
default 22:55:43.740439+0200    AltTab  keyboardHandler6: true
default 22:55:43.891484+0200    AltTab  keyboardHandler1: true, 12, 256
default 22:55:43.891558+0200    AltTab  keyboardHandler2: 256, 55
default 22:55:43.891710+0200    AltTab  actionHandler1: holdShortcut, false
default 22:55:43.891830+0200    AltTab  actionHandler2: false
default 22:55:43.891895+0200    AltTab  keyboardHandler3: false, false
default 22:55:43.891995+0200    AltTab  keyboardHandler6: true
default 22:55:45.787810+0200    AltTab  keyboardHandler1: true, 12, 1048840
default 22:55:45.787861+0200    AltTab  keyboardHandler2: 1048840, 55
default 22:55:45.787899+0200    AltTab  keyboardHandler3: false, false
default 22:55:45.787950+0200    AltTab  keyboardHandler6: true
default 22:55:46.083280+0200    AltTab  keyboardHandler1: true, 12, 256
default 22:55:46.083328+0200    AltTab  keyboardHandler2: 256, 55
default 22:55:46.083472+0200    AltTab  actionHandler1: holdShortcut, false
default 22:55:46.083513+0200    AltTab  actionHandler2: false
default 22:55:46.083561+0200    AltTab  keyboardHandler3: false, false
default 22:55:46.083616+0200    AltTab  keyboardHandler6: true
default 22:55:50.019309+0200    AltTab  keyboardHandler1: true, 12, 1048840
default 22:55:50.019347+0200    AltTab  keyboardHandler2: 1048840, 55
default 22:55:50.019376+0200    AltTab  keyboardHandler3: false, false
default 22:55:50.019424+0200    AltTab  keyboardHandler6: true
default 22:55:50.891154+0200    AltTab  keyboardHandler1: true, 12, 256
default 22:55:50.891196+0200    AltTab  keyboardHandler2: 256, 55
default 22:55:50.891261+0200    AltTab  actionHandler1: holdShortcut, false
default 22:55:50.891278+0200    AltTab  actionHandler2: false
default 22:55:50.891294+0200    AltTab  keyboardHandler3: false, false
default 22:55:50.891336+0200    AltTab  keyboardHandler6: true
default 22:56:07.531908+0200    AltTab  keyboardHandler1: true, 12, 1048840
default 22:56:07.531958+0200    AltTab  keyboardHandler2: 1048840, 55
default 22:56:07.531992+0200    AltTab  keyboardHandler3: false, false
default 22:56:07.532046+0200    AltTab  keyboardHandler6: true
default 22:56:08.812453+0200    AltTab  keyboardHandler1: true, 12, 256
default 22:56:08.812491+0200    AltTab  keyboardHandler2: 256, 55
default 22:56:08.812555+0200    AltTab  actionHandler1: holdShortcut, false
default 22:56:08.812571+0200    AltTab  actionHandler2: false
default 22:56:08.812587+0200    AltTab  keyboardHandler3: false, false
default 22:56:08.812645+0200    AltTab  keyboardHandler6: true
default 22:56:09.065196+0200    AltTab  keyboardHandler1: true, 12, 256
default 22:56:09.065241+0200    AltTab  keyboardHandler2: 256, 0
default 22:56:09.065268+0200    AltTab  #Error Unexpected key code 0 for the FlagsChanged event
default 22:56:09.065288+0200    AltTab  keyboardHandler3: false, false
default 22:56:09.065402+0200    AltTab  keyboardHandler6: true
default 22:56:10.019712+0200    AltTab  keyboardHandler1: true, 12, 1048840
default 22:56:10.019753+0200    AltTab  keyboardHandler2: 1048840, 55
default 22:56:10.019784+0200    AltTab  keyboardHandler3: false, false
default 22:56:10.019824+0200    AltTab  keyboardHandler6: true
default 22:56:10.411879+0200    AltTab  keyboardHandler1: true, 12, 256
default 22:56:10.411916+0200    AltTab  keyboardHandler2: 256, 55
default 22:56:10.411978+0200    AltTab  actionHandler1: holdShortcut, false
default 22:56:10.411993+0200    AltTab  actionHandler2: false
default 22:56:10.412009+0200    AltTab  keyboardHandler3: false, false
default 22:56:10.412049+0200    AltTab  keyboardHandler6: true
default 22:56:10.666240+0200    AltTab  keyboardHandler1: true, 12, 0
default 22:56:10.666296+0200    AltTab  keyboardHandler2: 0, 0
default 22:56:10.666328+0200    AltTab  #Error Unexpected key code 0 for the FlagsChanged event
default 22:56:10.666351+0200    AltTab  keyboardHandler3: false, false
default 22:56:10.666748+0200    AltTab  keyboardHandler6: true
default 22:56:13.804382+0200    AltTab  keyboardHandler1: true, 12, 1048840
default 22:56:13.804438+0200    AltTab  keyboardHandler2: 1048840, 55
default 22:56:13.804478+0200    AltTab  keyboardHandler3: false, false
default 22:56:13.804527+0200    AltTab  keyboardHandler6: true
default 22:56:15.228121+0200    AltTab  keyboardHandler1: true, 12, 256
default 22:56:15.228173+0200    AltTab  keyboardHandler2: 256, 55
default 22:56:15.228257+0200    AltTab  actionHandler1: holdShortcut, false
default 22:56:15.228281+0200    AltTab  actionHandler2: false
default 22:56:15.228303+0200    AltTab  keyboardHandler3: false, false
default 22:56:15.228352+0200    AltTab  keyboardHandler6: true
default 22:56:16.692225+0200    AltTab  keyboardHandler1: true, 12, 1048840
default 22:56:16.692266+0200    AltTab  keyboardHandler2: 1048840, 55
default 22:56:16.692298+0200    AltTab  keyboardHandler3: false, false
default 22:56:16.692380+0200    AltTab  keyboardHandler6: true

SecureInput grep check:

~ $ until false; do ioreg -l -w 0 | grep SecureInput | awk 'BEGIN {FS="[^a-zA-Z0-9]+"} {print $8}' | uniq | xargs -n 1 ps aux; sleep 1; done
USER   PID  %CPU %MEM      VSZ    RSS   TT  STAT STARTED      TIME COMMAND
neo    181   0.0  0.2  6701832 142584   ??  Ss   Sun05PM   0:10.35 /System/Library/CoreSe
USER   PID  %CPU %MEM      VSZ    RSS   TT  STAT STARTED      TIME COMMAND
neo    181   0.0  0.2  6701832 142584   ??  Ss   Sun05PM   0:10.35 /System/Library/CoreServices/loginwindow.app/Contents/MacOS/loginwindow console
USER   PID  %CPU %MEM      VSZ    RSS   TT  STAT STARTED      TIME COMMAND
neo    181   0.0  0.2  6701832 142584   ??  Ss   Sun05PM   0:10.35 /System/Library/CoreServices/loginwindow.app/Contents/MacOS/loginwindow console
USER   PID  %CPU %MEM      VSZ    RSS   TT  STAT STARTED      TIME COMMAND
neo    181   0.0  0.2  6701832 142584   ??  Ss   Sun05PM   0:10.35 /System/Library/CoreServices/loginwindow.app/Contents/MacOS/loginwindow console
USER   PID  %CPU %MEM      VSZ    RSS   TT  STAT STARTED      TIME COMMAND
neo    181   0.0  0.2  6701308 142576   ??  Ss   Sun05PM   0:10.35 /System/Library/CoreServices/loginwindow.app/Contents/MacOS/loginwindow console
USER   PID  %CPU %MEM      VSZ    RSS   TT  STAT STARTED      TIME COMMAND
neo    181   0.0  0.2  6701308 142576   ??  Ss   Sun05PM   0:10.35 /System/Library/CoreServices/loginwindow.app/Contents/MacOS/loginwindow console
USER   PID  %CPU %MEM      VSZ    RSS   TT  STAT STARTED      TIME COMMAND
neo    181   0.0  0.2  6701308 142576   ??  Ss   Sun05PM   0:10.35 /System/Library/CoreServices/loginwindow.app/Contents/MacOS/loginwindow console
USER   PID  %CPU %MEM      VSZ    RSS   TT  STAT STARTED      TIME COMMAND
neo    181   0.0  0.2  6701308 142576   ??  Ss   Sun05PM   0:10.35 /System/Library/CoreServices/loginwindow.app/Contents/MacOS/loginwindow console
USER   PID  %CPU %MEM      VSZ    RSS   TT  STAT STARTED      TIME COMMAND
neo    181   0.0  0.2  6701308 142576   ??  Ss   Sun05PM   0:10.35 /System/Library/CoreServices/loginwindow.app/Contents/MacOS/loginwindow console
USER   PID  %CPU %MEM      VSZ    RSS   TT  STAT STARTED      TIME COMMAND
neo    181   0.0  0.2  6701308 142576   ??  Ss   Sun05PM   0:10.35 /System/Library/CoreServices/loginwindow.app/Contents/MacOS/loginwindow console
USER   PID  %CPU %MEM      VSZ    RSS   TT  STAT STARTED      TIME COMMAND
neo    181   0.0  0.2  6701308 142576   ??  Ss   Sun05PM   0:10.35 /System/Library/CoreServices/loginwindow.app/Contents/MacOS/loginwindow console
USER   PID  %CPU %MEM      VSZ    RSS   TT  STAT STARTED      TIME COMMAND
neo    181   0.0  0.2  6701308 142576   ??  Ss   Sun05PM   0:10.35 /System/Library/CoreServices/loginwindow.app/Contents/MacOS/loginwindow console

FTR I'm running an unversioned (?) version you provided at some point via direct ZIP, sorry don't remember from where exactly, was a few weeks though now: image

just-Bri commented 4 years ago

Right now AltTab (and HyperSwitch as well!) refuse to listen to CMD-Tab. Totally. Even a restart does nothing (both apps).

That's an Apple thing. I've tried quite a few cmd-tab/alt-tab style apps to replace the standard osx cmd-tab ui and none of them will work with cmd-tab. It seems like Apple has that hard coded in the firmware, or something, so that you cannot overwrite it.

mfn commented 4 years ago

🤔

It works all the time, it just stopped in the middle "right now".

Probably need to restart the machine but don't want to right now 😄

lwouis commented 4 years ago

@reifnotreef there is no issue using cmd-tab. Try it out for yourself. Go in AltTab's preferences, and set cmd-tab to any shortcut. It will work.

@mfn so it's clearly Secure Input. If Secure Input is enabled, AltTab can't read any keyboard input. You have /System/Library/CoreServices/loginwindow.app/Contents/MacOS/loginwindow console enabling Secure Input and locking you out of AltTab.

I spent a few hours online looking for explanations, and it seems to be a known macOS bug. After login in your session, this loginwindow console process doesn't disable SecureInput. It should, but it doesn't. People have said that locking the screen, and re-entering password have worked for some of them. Others have had to logout and back login back in the session

I can only advise that you upgrade your macOS version in hope that Apple fixed that bug. What version are you on, at the moment?

Also thanks a lot for your diligence in running the test version I shared with you. Please feel free to update to the latest now. It contains numerous improvements and new features.

Finally, know that I'm working on a way to have AltTab work even when SecureInput is enabled. It's not supposed to be possible, but it may just be, thanks to Apple quality control. I'll keep everyone posted in this ticket if I make progress.

mfn commented 4 years ago

What version are you on, at the moment?

To the best of my knowledge, I'm on the latest: 10.15.6 (19G73)

Please feel free to update to the latest now

Thanks, done. Wohoo, dark mode icon 😄


I guess it was too late, I didn't realize this was the SecureInput issue despite running the very command; apologies. I guess I was too tired. In my mind I related …loginwindow console to the console.app I was having open 🤷‍♀️

just-Bri commented 4 years ago

@reifnotreef there is no issue using cmd-tab. Try it out for yourself. Go in AltTab's preferences, and set cmd-tab to any shortcut. It will work.

I have tried several times, with several different apps, and nothing will register the shortcut when assigned. Is there something in OSXs settings I need to change? It's extremely frustrating having different shortcuts between OS's.

lwouis commented 4 years ago

@reifnotreef hard to know what's wrong with your setup without more information. Are you using an external keyboard? Software like Karabiner, Synergy, anything that impacts the keyboard? Could you please see the information in this thread? It may be a similar scenario you're having, where other stuff gets in the way. AltTab itself supports binding to any shortcut. The only exception I know of is if a shortcut is already registered in System Preferences > Keyboard > Shortcuts, which is not the case for cmd+tab. Anyway, many people use AltTab with cmd+tab, so it is indeed possible

lwouis commented 4 years ago

To anyone interested

I've been working on a branch where I rewrote the keyboard handling using another API. It has different pros and cons compared to the current implementation:

Pros:

Cons:

I'm not sure what to do now. Should I release this? Maybe I should work on the cons, and figure out some breakthroughs? This stuff is a nightmare to work on btw 🙉

If you're interested, please try out this build and let me know if it works for you. Try it under Secure Input and try it with command+tab. Also be tricky and try all shorts of messy things like modifiers-only shortcuts, etc.

stidch commented 4 years ago

If you're interested, please try out this build and let me know if it works for you. Try it under Secure Input and try it with command+tab. Also be tricky and try all shorts of messy things like modifiers-only shortcuts, etc.

Working with this build the whole day without any problems so far. Usually AltTab stopped working because Secure Input quite soon. I'm using it with command+tab.

caduellery commented 4 years ago

2 things I use are not working well in this version:

lwouis commented 4 years ago

Fast switching with apparition delay of 100ms (had to set to 0ms and get a glitch)

~What do you mean? I don't get it. Maybe share a video to help visualize the issue?~

Edit: I was able to reproduce! This is another consequence of keyboard input being back on the main thread. That's unfortunate. I'll see if I can mitigate this

The use of Cmd+Shift+Tab to select previous window is bringing the default MacOS switcher in front of AltTab.

~Oh! I'll look into that. I'm using a private API to specifically disable the native switcher if the user sets the main shortcut to cmd-tab. I forgot about the shift shortcut!~

Edit: Ok I fixed that issue

lwouis commented 4 years ago

Here is a new build where I fixed both issues. I'll be on vacations for 9 days. Please everyone who can, take that time to test this build: AltTab.app.zip

The code is a mess, and I need to reorganize this so it's more approachable, but from my tests, it's looking good. The complexity of keyboard shortcuts being so customizable and combinations of preferences make it really hard to be confident though. That's why I need help with QA 👍

caduellery commented 4 years ago

Tested here and both fixes are OK, thanks! Found a new one: on the old version we can just hold Cmd+Tab pressed to cycle fast between windows thumbnails. Now holding the keys simply does nothing (seems like the "repeat" behavior of holding a key is disabled).

caduellery commented 4 years ago

Another one: when Alt+Tabbing the AltTab Preferences window is not showing itself in the list.

ghost commented 4 years ago

OK, I'll start using this test build from now until whenever to see if the problem remains or not!

zzamboni commented 4 years ago

I've also noticed that the AltTab preferences window does not show up in the switcher when using the test version.

Another change: with this version, Cmd-Shift-Tab no longer pops up the regular macOS application switcher as before (I had been using this as a workaround when I wanted to switch by apps).

ghost commented 4 years ago

Here is a new build where I fixed both issues. I'll be on vacations for 9 days. Please everyone who can, take that time to test this build: AltTab.app.zip

The code is a mess, and I need to reorganize this so it's more approachable, but from my tests, it's looking good. The complexity of keyboard shortcuts being so customizable and combinations of preferences make it really hard to be confident though. That's why I need help with QA 👍

Should we continue testing, or go back to main build? I'm still on this test build and seems to fix it, because I've forgotten about the bug completely. :)

lwouis commented 4 years ago

@mindfulsource I waited a bit, then as everyone reported good results, I merged the PR and closed this ticket. You can go back to the main/public release now