Why are you even using that option? Are you really using multiple desktops?
For those that don't know (i.e. most people), a
desktop in this sense is a specific, rarely-used facility introduced in Windows 2000. By "rarely-used" I mean that the vast majority of users see only the Winlogon desktop, the default desktop which is shown when a user logs in, and the ScreenSaver desktop which isolates the screensaver (and UAC prompts) from applications on the default desktop. Each process can only be associated with a single desktop, and cannot associate with some other desktop if it owns any windows. (Note: AutoHotkey scripts always own at least one window, though it is usually hidden.)
It is possible for third-party applications (including AutoHotkey) to
create and
switch to a desktop, but since it isn't possible to move windows between these desktops, it isn't generally useful. (However, it could be useful for kiosk-like applications.)
Since a process can't directly create a window on any desktop other than the one it is associated with, the MB_DEFAULT_DESKTOP_ONLY option of
MessageBox tells a system process (which resides on the default desktop) to create the message box window. You can confirm by using
WinGet, var, ProcessName, MsgBoxTitle - on my system it shows csrss.exe. This must also be the reason no visual style is applied to the MsgBox (on my system).
I imagine the option is used by non-interactive services, which (probably) aren't associated with any desktop and therefore can't directly create any windows.
While a modal dialog box is on-screen, the process which owns it runs a modal message loop. Since this MsgBox isn't owned by the script, no messages will be processed by the script while it is waiting for
MessageBox to return. This is evident in the script below:
Code:
SetTimer, show2, -100
MsgBox, 0, Test, No timeout
ExitApp
show2:
MsgBox, 0x20000, Test, Has timeout, 2
return
Until the "Has timeout" box is closed, the "No timeout" box, the script's tray icon and any other windows owned by the script will not respond. As soon as the "Has timeout" box closes, the script processes the "begin timeout" message - two seconds later it closes the top-most dialog, which is the "No timeout" box. Note that even if it were to receive and process the "begin timeout" message while the "Has timeout" box is visible, it looks specifically for the top-most dialog owned by the script's process (to avoid closing the wrong window), so would never find the MsgBox owned by csrss.exe (ironically, the right window).
Guest wrote:
If you have multiple monitors/desktops,
That is not what "desktop" means in this particular context.