I'm not sure how robust the activation of the previously focused window on mouse out is. The solutions for this kind of problem I've been able to find have been constructed for use with all windows not just a single specific one. I guess that might warrant more checks to actually get the right previous window and the right Z value and what not. I couldn't be bothered to actually find out why and this apparently works so... whatever. :)
edit (2013-12-07): Simplified the script... not sure why I thought the second timer was necessary. Now simply checks if cursor has moved and if so calls the title-check-activate-sub. And yes, I do realize that setting the ExStyle on every hover is a bit excessive but it is the lazy approach to the problem, hehe.
And now, after some swearing I have found out that the ^ in the WinSet command is used to toggle the style which is not what we want. Replaced with the proper +, yay. That's what you get for copy-pasting and not researching on you own, I know it but I still do it, pfft.
#SingleInstance force #Persistent #NoEnv ;// --------------------------------- ;// Init ;// --------------------------------- SetWinDelay, -1 CoordMode, Mouse, Screen vm_title := "name_of_VM [Running] - Oracle VM VirtualBox" SetTimer, HoverCheck, 100 return ;// --------------------------------- ;// Activate VM on hover ;// --------------------------------- HoverCheck: MouseGetPos, x, y if (x != lastx or y != lasty) { GoSub, hovering lastx := x lasty := y } return Hovering: MouseGetPos,,, win WinGetTitle, tl, ahk_id %win% if (tl = vm_title) { if (!WinActive("ahk_id " win)) { WinGet, prevWin, ID, A WinActivate, ahk_id %win% WinSet, ExStyle, +0x80, ahk_id %win% ;// hides the VM window from alt+tab } } else if (prevWin != "") { WinActivate, ahk_id %prevWin% prevWin := "" } return