72

I have recently gone through this issue. I am running Lubuntu 13.04 in VirtualBox .So when I have maximized and if I would like switch to next window of main system usually we all do ALT+TAB but thats not getting for main system and going for Vbox's Lubuntu .

So how can i get activated main system ALT+TAB functionality even i have a maximized VirtaulBox operating system .

Thank you .

65
  1. Enter into VirtualBox

  2. Press the Host key.

    • The default Host key is the right Ctrl key.
    • On macOS, the default Host key is the right Command key.
    • The previous version of this answer listed the Alt key.
  3. NowALT + TABshould work.

Regarding the Host key from VirtualBox Manual Ch. 1

To return ownership of keyboard and mouse to your host operating system, VirtualBox reserves a special key on your keyboard for itself: the "host key". By default, this is the right Control key on your keyboard; on a Mac host, the default host key is the left Command key. You can change this default in the VirtualBox Global Settings, see Section 1.15, “Global Settings”. In any case, the current setting for the host key is always displayed at the bottom right of your VM window, should you have forgotten about it

5
  • 1
    This is not entirely correct. It looks like you want to press the "Host" key. In the case of those who up-voted this, their host key must have been one of the Alt keys. For me, it's the Right Ctrl key. ron.shoutboot.com/2010/09/11/alt-tab-out-of-virtualbox – Dave Jensen Jan 22 '15 at 4:13
  • 3
    Curious how to accomplish the opposite. Alt tabbing is always swapping Windows applications rather than those within my Ubuntu VM. How does one "undo" this? – kuanb Jan 23 '17 at 17:16
  • 1
    Great, works very well, but just a side node: You have to press and release Host key in step 2, before doing Alt-Tab... – Hartmut Pfarr Oct 1 '17 at 18:27
  • geniuuuuuuuuuus – Damián Rafael Lattenero Oct 26 '18 at 22:46
  • @Dave Jensen Yay. This is the answer to my probably not so unusual case (CTRL+ALT is the standard host key). Thanks alot. – JackLeEmmerdeur Sep 3 '19 at 0:38
68

My solution: VirtualBox: File -> Preferences -> Input -> uncheck "Auto Capture Keyboard"

5
  • 12
    This is a great solution when you're working with only one application in seamless mode. Thanks! – Brandon Bertelsen Dec 20 '14 at 21:52
  • 13
    What kind of sorcery is this? I use Virtualbox for YEARS and now you tell I can have a single window just like I'm running an X server on my windows box? This is awesome! – Hugo Dec 20 '16 at 14:51
  • 1
    Love you. It makes for a great development environment: a GNU/Linux VM with all the programming stuff in it and your text editor running. And the terminal using SSH. The reason for having my text editor in my VM is so that it can interact with libs (git, npm, goimports, linters, etc). – tleb Jul 22 '17 at 23:36
  • 1
    It's a bit buggy but it kind of does the job. – KeyC0de Apr 6 '18 at 23:40
  • 1
    Super ! Saved my ass !!! – user218867 Mar 4 '19 at 11:22
4

Because I use my left hand to do Alt+Tab, I personally set my Host key to be Left Ctrl. This makes it much more easy to switch if you have your right hand sitting on the mouse: press Left Ctrl then Alt+Tab.

2
  • 2
    For anyone else who stumbles upon this comment and is confused, "Strg" is the abbreviation for "Steuerung", the German name for the Control key. – Eagle-Eye Aug 29 '16 at 18:30
  • 1
    @Eagle-Eye Thanks, I incorporated that into the answer. – wjandrea Oct 20 '16 at 16:28
4

Two part solution:

(1) My solution: VirtualBox: File -> Preferences -> Input -> uncheck Auto Capture Keyboard (taken from @baronbaleron above)

(2) Remap Cycle through open windows to ctrl+tab. In Linux Mint (a derivative of Ubuntu): Start menu -> Keyboard -> Shortcuts -> General -> Cycle through open windows -> change binding to ctrl + tab

0

On MacOS: (Control + ALT) then Tab

In the VM I'm using, I also have to hit Enter after this..which is slightly annoying.

0

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%
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.