windows - 在 python 上使用 ctypes 不显示多个消息框

标签 windows python-2.7 ctypes messagebox

嗨,我有一个简单的代码,使用 ctypes 显示消息框 但我的问题是在我添加 MB_TOPMOST 后它没有附加或重叠消息框?

def msgbox(self,msg):
        MB_OK = 0x0
        MB_OKCXL = 0x01
        MB_YESNOCXL = 0x03
        MB_YESNO = 0x04
        MB_HELP = 0x4000
        ICON_EXLAIM=0x30
        ICON_INFO = 0x40
        ICON_STOP = 0x10
        MB_TOPMOST=0x40000
        """
                HEX VALUE LINK
        https://www.autoitscript.com/autoit3/docs/functions/MsgBox.htm
        """
        writeLogs = WriteLogs(
                    pathLog = app_config['path_logs'] +"\\"+strftime("%Y_%m_%d")+".log",
                    timedate = time.strftime("%m/%d/%Y %I:%M:%S %p")
                    )
        writeLogs.appendLogA(msg)
        ctypes.windll.user32.MessageBoxA(None, msg+str(operatorMessage), "[Error]", MB_OK | ICON_STOP | MB_TOPMOST)

最佳答案

我尝试将 MB_TOPMOST 更改为 MB_SYSTEMMODAL 以及我想要的输出,其中包含最上面和重叠的消息错误框。

您可以引用这个链接: https://msdn.microsoft.com/en-us/library/windows/desktop/ms645505%28v=vs.85%29.aspx

stackoverflow 上的这篇文章给了我一个想法: Have Win32 MessageBox appear over other programs

def msgbox(self,msg):
        MB_OK = 0x0
        MB_OKCXL = 0x01
        MB_YESNOCXL = 0x03
        MB_YESNO = 0x04
        MB_HELP = 0x4000
        ICON_EXLAIM=0x30
        ICON_INFO = 0x40
        ICON_STOP = 0x10
        MB_TOPMOST=0x40000
        MB_SYSTEMMODAL=0x1000
        """
                HEX VALUE LINK
        https://www.autoitscript.com/autoit3/docs/functions/MsgBox.htm
        """
        writeLogs = WriteLogs(
                    pathLog = app_config['path_logs'] +"\\"+strftime("%Y_%m_%d")+".log",
                    timedate = time.strftime("%m/%d/%Y %I:%M:%S %p")
                    )
        writeLogs.appendLogA(msg)
        ctypes.windll.user32.MessageBoxA(None, msg+str(operatorMessage), "[Error]", MB_OK | ICON_STOP | MB_SYSTEMMODAL)

关于windows - 在 python 上使用 ctypes 不显示多个消息框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35354552/

相关文章:

Windows 上的 node.js 经常失败并显示 'EMFILE: too many open files'

Python - 将字符传递给 C 库

python - argv 的 ctypes 错误

c++ - Windows编程教程中未解析的外部符号__RTC_*

c# - WinRT XAML TextBlock - 超链接功能

python - Windows 上带有套接字包装器的 `OSError: [Errno 9] Bad file descriptor`

python - 操作系统 X : python ctypes global variables

python - 在python OpenCV中使用特定的高度和宽度调整和填充图像会导致错误和不准确的结果

python-2.7 - 使用python和tkinter在按钮单击上调用python脚本

python - 无法使用 python PDFKIT 错误 : "No wkhtmltopdf executable found:" 创建 pdf