-
-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Window does not auto-focus to foreground upon changing virtual desktops #77
Comments
In absence of other solutions I was able to fix this by adding
line to |
another solution (by mzomparelli) _SwitchDesktop(IVirtualDesktop) {
;activate taskbar before ;https://github.com/mzomparelli/zVirtualDesktop/issues/59#issuecomment-317613971
WinActivate, ahk_class Shell_TrayWnd
WinWaitActive, ahk_class Shell_TrayWnd
this._dll_SwitchDesktop(IVirtualDesktop)
this._dll_SwitchDesktop(IVirtualDesktop)
WinMinimize, ahk_class Shell_TrayWnd
} I Don't know how equivalent function: !2::VD.goToDesktopNum(2) I don't know what DllCall("User32\AllowSetForegroundWindow", "Int",-1) ;ASFW_ANY is -1 ;https://www.reddit.com/r/AutoHotkey/comments/qvkjhh/comment/hkx42s7/?utm_source=share&utm_medium=web2x&context=3 |
Add this code in the end of if block,this works. thanks. |
Thank you so much. I had a really hard time working without this fix for a couple of weeks. Should I make a pull request for this? |
Use built-in hotkey Alt-Escape instead of manually invoking WinActivate. Credits: pmb6tz/windows-desktop-switcher#77 (comment) Restoring the windows focus is actually necessary because of the WinActivate(Shell_TrayWnd) which in turn fixes the taskbar flashing.
If I'm on Desktop 1 and press alt+2 to go to Desktop 2, the full-screen app on Desktop 2 is not in "focus" in the foreground and requires clicking the window or pressing alt+tab to bring the window into focus. I only have 1 app running on every Virtual Desktop, so I would just like that window to automatically be called to the foreground as soon as I switch to that Desktop so that I can simply use a key command to do something like focus the URL bar and begin searching the web. Currently, when I switch Desktops using the keyboard shortcut, I have to press alt+tab or click the window every time in order to bring focus to the window and begin typing in it.
In researching the issue, it sounds like someone has an idea to fix it that has been given a couple of "thumbs ups" to indicate it works, but I'm not a coder and don't really know how to implement it. Could this be inserted into the existing AHK script somehow?
"I was able to resolve this by calling AllowSetForegroundWindow(ASFW_ANY) before calling GoToDesktopNumber(). Presumably AutoHotKey does this, but I had to do it explicitly." I found that at the bottom of this github post.
The text was updated successfully, but these errors were encountered: