Ciantic / VirtualDesktopAccessor

DLL for accessing Windows 11/10 Virtual Desktop features from e.g. AutoHotkey
MIT License
773 stars 93 forks source link

Window focus stays at previous virtual desktop #4

Closed c0ffeeartc closed 8 years ago

c0ffeeartc commented 8 years ago

When I switch worskpaces through hotkey - focus stays on the old workspace, and keypresses are received by previous window. I have partial solution, that has other drawbacks

#u::
    DllCall(GoToDesktopNumberProc, Int, 0)
    Send, {ALT DOWN}{TAB}{ALT UP}
return
#i::
    DllCall(GoToDesktopNumberProc, Int, 1)
    Send, {ALT DOWN}{TAB}{ALT UP}
return

Anyone else experienced issue, is there a better solution workaround ?

Ciantic commented 8 years ago

This is also an issue in the Windows 10 virtual desktop implementation. If I use "Win+Ctrl+Right" to switch back and forth, only the window where I left remains focused.

It would be better to open issues in Microsoft connect, if I could figure out where in there.

Ciantic commented 8 years ago

See e.g. this: http://superuser.com/questions/1004074/windows-10-automatically-focus-windows-on-virtual-desktops it's known issue (one of many) in Windows 10 virtual desktop implementation.

Ciantic commented 8 years ago

I'm closing this, initial test shows this does something like that:

RegisterPostMessageHookProc := DllCall("GetProcAddress", Ptr, hVirtualDesktopAccessor, AStr, "RegisterPostMessageHook", "Ptr")
DllCall(RegisterPostMessageHookProc, Int, hwnd, Int, 0x1400 + 30)
OnMessage(0x1400 + 30, "VWMess")
VWMess(wParam, lParam, msg, hwnd) {
    ; ...
    Send !{Esc} ; ALT+Esc activates last window
}

EDIT: It seems like it activates wrong window at times, but the point remains, if someone finds a way to call "ALT+TAB" once in the same location it should work.

But it's not an issue in this DLL/wrapper itself, it's a missing feature in Windows 10 desktop implementation.

c0ffeeartc commented 8 years ago

Yes. I confirm that Ctrl+Win+Arrow loses focus. Alt+Esc works great for me.

tom-bowles commented 5 years ago

I get this behaviour, but only with VirtualDesktopAccessor. I'm simply calling GoToDesktopNumber() (not using autohotkeys). Ctrl+Win+Arrow does not have this behaviour for me.

tom-bowles commented 5 years ago

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.