I know it’s a weird question but the scenario is that I am a Windows user and I made a script which reports “something” with a sound in a Debian virtual machine, but when I have it minimized I can not hear the sound.
I wonder if there is a way to listen to the audio of a virtual machine while it’s in the background?
I cannot test it on Windows because I’m using Linux but I found this feature request in which the opener would like to have the feature that the sound gets minimized when window has been minimized. This makes me assume that your problem happens because of a Windows settings (somewhere) and not a VirtualBox setting as VirtualBox seems not to have that “feature”.
An alternative might be to use
Seamless Mode. This integrates windows (and alert boxes) from the guest OS into the current Windows desktop session. This way you should be able to hear the sound.
To achieve this, select “View” in the menu bar of the VM window and then “Switch to seamless mode”