This allows you to use Win+Tab on the Guest Machine, while Alt+Tab will be passed to the host. I really miss this functionality when I don't have it.
It also works with Windows Remote Desktop Connection.
Under VitualBox's menu, goto File > Preferences > Input and make sure [ ] Auto Capture Keyboard
is unchecked. This can't work with it checked.
It requires AutoHotKey (or a similar scripting platform, you'll have to research syntax for that) to be ran on the Host and Guest system. You can do a similar script on just the Host, but you'd have to press Alt after each use of Win+Tab on the Guest machine to release the key-state.
This was written for a Windows 10 Host to a Windows 10 Guest, but I see no reason this can't work with other Guests. There are programs like AutoHotKey that may allow other Host OSs to do something like this.
Both scripts be run in Administrator to be able to monitor processes that are also run as Administrator.
Host Machine
Install this on the host machine as, for instance, WinTabHost.ahk.
#SingleInstance, Force
hostkey = RCTRL ; set this to your VirtualBox HOSTKEY
boxMode := ""
Hotkey, <#Tab, WinTabbing
Hotkey, >#Tab, WinTabbing
Return
TabFinish:
Send, {ALT UP}
RDCKeysState("Off")
Return
Tabbing:
Send, {Right}
Return
WinTabbing:
WinGetTitle, Title, A
StringRight, TitleEnd, Title, 25
RDCKeysState("On")
If (InStr(Title, "[Running] - Oracle VM VirtualBox")) { ; Guest mode
Send, {%hostkey%} ; Trigger capture-state
Sleep, 200 ; Sleep to give the machine time to process, just in case
Send, #{TAB} ; Send Win+Tab
Send, {%hostkey%} ; Release capture-state
} Else If (TitleEnd = "Remote Desktop Connection") and (not Title = "Remote Desktop Connection") { ; RDC mode
Send, {Alt down}{PgDn} ; Press and hold alt, and press pgdn
} Else { ; Host mode
Send, {ALT Down}{TAB}
Sleep, 200 ; Sleep to wait a split-second for Alt-Tab window to appear
iter := 0 ; loop tracker
Loop {
iter := iter+1
if (!WinExist("Task Switching") Or iter > 60) { ; If Alt+tab is gone, or it's been 30 seconds
Send, {ALT UP}
Break
}
Sleep, 500
}
}
Return
RDCKeysState(toggle) {
; This function maps all the ways that a user might end the alt-tab box.
Hotkey, Enter, TabFinish, %toggle% ; Map Enter, Click, and their alt-counterparts to TabFinish()
Hotkey, !Enter, TabFinish, %toggle%
Hotkey, LButton, TabFinish, %toggle%
Hotkey, !LButton, TabFinish, %toggle%
Hotkey, *LWIN UP, TabFinish, %toggle%
Hotkey, *RWIN UP, TabFinish, %toggle%
Hotkey, *Tab, Tabbing, %toggle%
}
; if you get the error 'could not close the previous instance of the script,`
; while ever trying to reload the script, you need to right click it and select
; 'Run As Administrator'
Guest Machine
Install this on the guest machine as, for instance, WinTabGuest.ahk.
#SingleInstance, Force
SetWorkingDir %A_ScriptDir%
if (not A_IsAdmin) {
Run *RunAs "%A_ScriptFullPath%" ; Run as administrator to detect keystrokes focued on Elevated Programs
}
Hotkey, <#Tab, WinTabbing
Return
TabFinish:
Tooltip, TabOut
Send, {ALT UP}
RDCKeysState("Off")
Return
Tabbing:
Send, {Right}
Return
WinTabbing:
Send {Alt DOWN}{TAB}
RDCKeysState("On")
Sleep, 200
iter := 0
Loop
{
iter := iter+1
Sleep, 200
if (!WinExist("Task Switching") Or iter >= 60) {
Send, {ALT UP}
Break
}
Sleep, 500
}
Return
RDCKeysState(toggle) {
Hotkey, Enter, TabFinish, %toggle%
Hotkey, !Enter, TabFinish, %toggle%
Hotkey, LButton, TabFinish, %toggle%
Hotkey, !LButton, TabFinish, %toggle%
Hotkey, *LWIN UP, TabFinish, %toggle%
Hotkey, *RWIN UP, TabFinish, %toggle%
Hotkey, *Tab, Tabbing, %toggle%
}