예제 #1
0
def NonBlockingMessageBox(hwnd, message, title, style=0, language=0):
    """MessageBox function that does not block. 
For example:
    NonBlockingMessageBox(0, "Twinkle twinkle\nlittle star","Song", win32con.MB_ICONINFORMATION)
    """
    #
    # win32api.MessageBox(hwnd, message, title, style, language)
    #
    if hwnd == 0:
        hwnd = win32gui.GetDesktopWindow()
    if language == 0:
        language = win32api.MAKELANGID(win32con.LANG_NEUTRAL,
                                       win32con.SUBLANG_DEFAULT)
    if style == 0:
        style = win32con.MB_OK
    args = (hwnd, message, title, style, language)
    t = threading.Thread(target=win32api.MessageBox, args=args)
    t.start()
예제 #2
0
def ShowSystemErrorMessge(nError):
    #print "ShowSystemErrorMessge"
    #string = win32api.FormatMessage(errCode)
    lpMsgBuf = win32api.FormatMessage(\
        win32con.FORMAT_MESSAGE_ALLOCATE_BUFFER |\
        win32con.FORMAT_MESSAGE_FROM_SYSTEM |\
        win32con.FORMAT_MESSAGE_IGNORE_INSERTS,\
        NULL,\
        nError,\
        win32api.MAKELANGID(win32con.LANG_NEUTRAL, win32con.SUBLANG_NEUTRAL)\
        , None)

    #//format and show system error message
    #LPVOID lpMsgBuf;
    #FormatMessage(  FORMAT_MESSAGE_ALLOCATE_BUFFER |
    #                FORMAT_MESSAGE_FROM_SYSTEM |
    #                FORMAT_MESSAGE_IGNORE_INSERTS,
    #                NULL,
    #                nError,
    #                MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
    #                (LPTSTR) &lpMsgBuf, 0, NULL );
    wxMessageBox(lpMsgBuf, str(nError))
예제 #3
0
파일: hello.py 프로젝트: tonejin/demo
#! python3
# _*_ coding:utf-8 _*
# @Author   : Jin Tone
# Date      : 2018/2/24

import win32api
import win32con

win32api.MessageBox(win32con.NULL, "Good morning, Fishc!", "操你", win32con.MB_OKCANCEL, win32api.MAKELANGID(win32con.LANG_ENGLISH, win32con.LANG_CHINESE))


예제 #4
0
"""Event Log Utilities - helper for win32evtlog.pyd
"""

import win32api, win32con, winerror, win32evtlog

error = win32api.error # The error the evtlog module raises.

langid = win32api.MAKELANGID(win32con.LANG_NEUTRAL, win32con.SUBLANG_NEUTRAL)

def AddSourceToRegistry(appName, msgDLL = None, eventLogType = "Application", eventLogFlags = None):
    """Add a source of messages to the event log.

    Allows Python program to register a custom source of messages in the
    registry.  You must also provide the DLL name that has the message table, so the
    full message text appears in the event log.

    Note that the win32evtlog.pyd file has a number of string entries with just "%1"
    built in, so many Python programs can simply use this DLL.  Disadvantages are that
    you do not get language translation, and the full text is stored in the event log,
    blowing the size of the log up.
    """

    # When an application uses the RegisterEventSource or OpenEventLog
    # function to get a handle of an event log, the event loggging service
    # searches for the specified source name in the registry. You can add a
    # new source name to the registry by opening a new registry subkey
    # under the Application key and adding registry values to the new
    # subkey.

    if msgDLL is None:
        msgDLL = win32evtlog.__file__