Home>

The message box is displayed using user32 in python.
The code below hides behind other windows,
Is there any way to bring it to the forefront?

def msg (ttl, val, box = 64):
    import ctypes as ct
    u32 = ct.WinDLL ('user32')
    return u32.MessageBoxW (0, val, ttl, box)
  • Answer # 1

    How about specifying MB_SETFOREGROUND (0x10000) for uType of MessageBoxW?
    (return u32.MessageBoxW (0, val, ttl, box | 0x10000))

    Although I can't recommend it too much, I think there is a way to make it system modal by adding MB_SYSTEMMODAL (0x1000) to uType.

Related articles