sigoden / window-switcher

Easily switch between windows of the same app with Alt+` (Backtick), also switch between apps with Alt+Tab.
MIT License
607 stars 23 forks source link

Loosing focus after switching apps quicly #93

Closed phcamargo23 closed 8 months ago

phcamargo23 commented 8 months ago

When switching a window, focus is lost. From what you can see, it only happens that we change the window quickly. If you toggle smoothly, the focus remains, but if you do it quickly, it appears to trigger an automatic "alt" press, causing the focus to go to the toolbar.

https://github.com/sigoden/window-switcher/assets/5577637/3a3979af-5f90-4a43-ad95-e105cc1f83c4

My PC configurations is: image

My file configurations is:

a# Whether to show trayicon, yes/no
trayicon = yes 

[switch-windows]

# Hotkey to switch windows
hotkey = alt+`

# List of hotkey conflict apps
# e.g. game1.exe,game.exe
blacklist =

# Ignore minimal windows
ignore_minimal = no

[switch-apps]

# Whether to enable switching apps
enable = yes

# Hotkey to switch apps
hotkey = alt+tab

# Ignore minimal windows
ignore_minimal = no
sigoden commented 8 months ago

There is no way to solve this issue.

stianhoiland commented 7 months ago

This issue is certainly solvable. I have gotten similar non-answers (#80, #81, #82, #83). Reading other issues, this seems to be a pattern with this developer. For a switcher without this issue, see cmdtab, of which I'm the author, after frankly being pissed by the responses I got here.

sigoden commented 7 months ago

This problem cannot be completely solved.

If you press the key too quickly, the keystrokes at a certain moment may be detect as two keyevents: alt+tab and alt

The alt+tab will switch to the next app, alt will activate menu, then a bug appeared.

I closed #81 #82 #83 because I didn't think it was necessary, This issue is closed because it cannot be resolved. This is no pattern.

If other people's open source projects cannot meet the demand, start a new project. I appreciate this behavior very much. I often do this myself.

joelcho commented 7 months ago

As sigoden mentioned, clicking the Alt key on Windows defaults to focusing on the Menu or Tool bar.

In fact, many people have been troubled by this and have provided some excellent solutions. Moreover, many excellent software programs allow you to modify this behavior in the preferences settings. Please refer to the following link:

Additionally, using AutoHotkey can globally block/change this behavior.

@phcamargo23

stianhoiland commented 7 months ago

Yeah; individually configure every app to workaround window-switcher's limitations (and just live with the ones that can't be configured this way, like Chrome), or install a different app to perpetually run a script in the background to workaround window-switcher's limitations...

Or use cmdtab which does the impossible /s and doesn't have this issue.

Yeah, now I remember why I got so pissed by these inane responses and made my own.

sigoden commented 7 months ago

Your cmdtab don't have alt problem, but does have tab problem.

Using delay and discarding alt key events did not completely solve the problem. @stianhoiland

stianhoiland commented 7 months ago

I don't know what you mean by "tab problem". Feel free to create an issue—I'm sure it can be fixed, and thus will be fixed, if it even exists.

And yes, the Alt key problem is solvable, as I've said and demonstrated. cmdtab's optional GUI delay has nothing to do with it. Correctly consuming and passing Alt key events is (and is part of a better approach to keyboard handling in cmdtab), as well as correctly using the SetForegroundWindow Alt key hack.

sigoden commented 7 months ago

Repeatedly pressing alt+tab to switch windows quickly as described in the issue,window-switcher capture additional alt keyevent (focus menu), cmdtab capture additional tab keyevent (insert tab).

stianhoiland commented 7 months ago

In cmdtab, quickly and repeatedly pressing Alt+Tab, Alt+Tab, Alt+Tab, or holding Alt and pressing Tab, Tab, Tab, does not produce any unexpected or unwanted additional Tab key events (and doesn't insert any additional tabs in text fields, nor selects next control).

Please create an issue, preferably with evidence and steps to reproduce, like @phcamargo23 took the time to do in this current issue. At this point I suspect you're just making shit up.

sigoden commented 7 months ago

See the video. Repeatedly pressing alt+tab to switch windows quickly.

https://github.com/sigoden/window-switcher/assets/4012553/99932282-3cff-41c8-b287-34f4ff329552

stianhoiland commented 7 months ago

You're fucking kidding me, right? I can see you being sloppy with pressing the keys, leading to you pressing Tab while you're not simultaneously holding Alt. Scumbag. To prove you're bullshit I made a AutoHotkey script that spams Alt+Tab 100 times while cmdtab is running and recorded it (video size reduced by frame dedup):

https://github.com/sigoden/window-switcher/assets/2081712/4246d218-f38d-47a3-bfac-8a9b715368d1

Not a single tab inserted. And not a single additional Alt key event.

Why tf am I still here. Apparently I didn't properly learn my lesson the first time I interacted with you. Please refrain from anymore false comments about cmdtab.

sigoden commented 7 months ago

Why do you still not understand this issue? If you can keep alt+tab being triggered at the same time every time, there will be no problem at all. Use two fingers to quickly press the alt key and the tab key. When the speed becomes faster, the key presses at a certain moment may be detected as two key press events: (alt+tab+alt), ( alt+tab + tab). That's why the bug occurs. @stianhoiland