当前位置: 首页>>代码示例>>Python>>正文


Python win32gui.error方法代码示例

本文整理汇总了Python中win32gui.error方法的典型用法代码示例。如果您正苦于以下问题:Python win32gui.error方法的具体用法?Python win32gui.error怎么用?Python win32gui.error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在win32gui的用法示例。


在下文中一共展示了win32gui.error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _CreateMainWindow

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import error [as 别名]
def _CreateMainWindow(self, prev, settings, browser, rect):
        # Creates a parent window that hosts the view window.  This window
        # gets the control notifications etc sent from the child.
        style = win32con.WS_CHILD | win32con.WS_VISIBLE #
        wclass_name = "ShellViewDemo_DefView"
        # Register the Window class.
        wc = win32gui.WNDCLASS()
        wc.hInstance = win32gui.dllhandle
        wc.lpszClassName = wclass_name
        wc.style = win32con.CS_VREDRAW | win32con.CS_HREDRAW
        try:
            win32gui.RegisterClass(wc)
        except win32gui.error, details:
            # Should only happen when this module is reloaded
            if details[0] != winerror.ERROR_CLASS_ALREADY_EXISTS:
                raise 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:shell_view.py

示例2: __init__

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import error [as 别名]
def __init__(self):
        msg_TaskbarRestart = win32gui.RegisterWindowMessage("TaskbarCreated");
        message_map = {
                msg_TaskbarRestart: self.OnRestart,
                win32con.WM_DESTROY: self.OnDestroy,
                win32con.WM_COMMAND: self.OnCommand,
                win32con.WM_USER+20 : self.OnTaskbarNotify,
        }
        # Register the Window class.
        wc = win32gui.WNDCLASS()
        hinst = wc.hInstance = win32api.GetModuleHandle(None)
        wc.lpszClassName = "PythonTaskbarDemo"
        wc.style = win32con.CS_VREDRAW | win32con.CS_HREDRAW;
        wc.hCursor = win32api.LoadCursor( 0, win32con.IDC_ARROW )
        wc.hbrBackground = win32con.COLOR_WINDOW
        wc.lpfnWndProc = message_map # could also specify a wndproc.

        # Don't blow up if class already registered to make testing easier
        try:
            classAtom = win32gui.RegisterClass(wc)
        except win32gui.error, err_info:
            if err_info.winerror!=winerror.ERROR_CLASS_ALREADY_EXISTS:
                raise

        # Create the Window. 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:27,代码来源:win32gui_taskbar.py

示例3: create_desktop

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import error [as 别名]
def create_desktop(desktop_name, start_explorer=1):
    """ Creates a new desktop and spawns a thread running on it
        Will also start a new icon thread on an existing desktop
    """
    sa=pywintypes.SECURITY_ATTRIBUTES()
    sa.bInheritHandle=1

    try:
        hdesk=win32service.CreateDesktop(desktop_name, 0, win32con.MAXIMUM_ALLOWED, sa)
    except win32service.error:
        traceback.print_exc()
        errbuf=cStringIO.StringIO()
        traceback.print_exc(None,errbuf)
        win32api.MessageBox(0, errbuf.getvalue(), 'Desktop creation failed')
        return
    if start_explorer:
        s=win32process.STARTUPINFO()
        s.lpDesktop=desktop_name
        prc_info=win32process.CreateProcess(None, "Explorer.exe",None,None,True,win32con.CREATE_NEW_CONSOLE,None,'c:\\',s)

    th=thread.start_new_thread(new_icon,(hdesk,desktop_name))
    hdesk.SwitchDesktop() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:24,代码来源:desktopmanager.py

示例4: findSpecifiedWindows

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import error [as 别名]
def findSpecifiedWindows(top_hwnd, numChildWindows=70):
    '''
    查找某一窗口下指定数量的子窗口
    :param top_hwnd: 主窗口句柄
    :param numChildWindows: 子窗口数量
    :return:子窗口列表,包括子窗口hwnd, title, className
    '''
    windows = []
    try:
        win32gui.EnumChildWindows(top_hwnd, _windowEnumerationHandler, windows)
    except win32gui.error:
        # No child windows
        return
    for window in windows:
        childHwnd, windowText, windowClass = window
        windowContent = dumpSpecifiedWindow(childHwnd)
        if len(windowContent) == numChildWindows:
            return windowContent
    # 没有指定数量的句柄
    return 
开发者ID:wangdkchina,项目名称:pyautotrade_tdx,代码行数:22,代码来源:winguiauto.py

示例5: _RegisterWndClass

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import error [as 别名]
def _RegisterWndClass(self):
        message_map = {}
        wc = win32gui.WNDCLASS()
        wc.SetDialogProc()  # Make it a dialog class.
        wc.hInstance = self.hinst
        wc.lpszClassName = self.className
        wc.style = win32con.CS_VREDRAW | win32con.CS_HREDRAW
        wc.hCursor = win32gui.LoadCursor(0, win32con.IDC_ARROW)
        wc.hbrBackground = win32con.COLOR_WINDOW + 1
        wc.lpfnWndProc = message_map  # could also specify a wndproc.
        wc.cbWndExtra = win32con.DLGWINDOWEXTRA + struct.calcsize("Pi")

        try:
            self.classAtom = win32gui.RegisterClass(wc)
        except win32gui.error, err_info:
            if err_info.winerror != winerror.ERROR_CLASS_ALREADY_EXISTS:
                raise 
开发者ID:eavatar,项目名称:eavatar-me,代码行数:19,代码来源:console.py

示例6: CreateViewWindow

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import error [as 别名]
def CreateViewWindow(self, prev, settings, browser, rect):
        print "ScintillaShellView.CreateViewWindow", prev, settings, browser, rect
        # Make sure scintilla.dll is loaded.  If not, find it on sys.path
        # (which it generally is for Pythonwin)
        try:
            win32api.GetModuleHandle("Scintilla.dll")
        except win32api.error:
            for p in sys.path:
                fname = os.path.join(p, "Scintilla.dll")
                if not os.path.isfile(fname):
                    fname = os.path.join(p, "Build", "Scintilla.dll")
                if os.path.isfile(fname):
                    win32api.LoadLibrary(fname)
                    break
            else:
                raise RuntimeError("Can't find scintilla!")

        style = win32con.WS_CHILD | win32con.WS_VSCROLL | \
                win32con.WS_HSCROLL | win32con.WS_CLIPCHILDREN | \
                win32con.WS_VISIBLE
        self.hwnd = win32gui.CreateWindow("Scintilla", "Scintilla", style,
                              rect[0], rect[1], rect[2]-rect[0], rect[3]-rect[1], 
                              self.hwnd_parent, 1000, 0, None)

        message_map = {
                win32con.WM_SIZE: self.OnSize,
        }
#        win32gui.SetWindowLong(self.hwnd, win32con.GWL_WNDPROC, message_map)

        file_data = file(self.filename, "U").read()

        self._SetupLexer()
        self._SendSci(scintillacon.SCI_ADDTEXT, len(file_data), file_data)
        if self.lineno != None:
            self._SendSci(scintillacon.SCI_GOTOLINE, self.lineno)
        print "Scintilla's hwnd is", self.hwnd 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:38,代码来源:shell_view.py

示例7: _RegisterWndClass

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import error [as 别名]
def _RegisterWndClass(self):
        className = "PythonDocSearch"
        message_map = {}
        wc = win32gui.WNDCLASS()
        wc.SetDialogProc() # Make it a dialog class.
        wc.hInstance = self.hinst
        wc.lpszClassName = className
        wc.style = win32con.CS_VREDRAW | win32con.CS_HREDRAW
        wc.hCursor = win32gui.LoadCursor( 0, win32con.IDC_ARROW )
        wc.hbrBackground = win32con.COLOR_WINDOW + 1
        wc.lpfnWndProc = message_map # could also specify a wndproc.
        # C code: wc.cbWndExtra = DLGWINDOWEXTRA + sizeof(HBRUSH) + (sizeof(COLORREF));
        wc.cbWndExtra = win32con.DLGWINDOWEXTRA + struct.calcsize("Pi")
        icon_flags = win32con.LR_LOADFROMFILE | win32con.LR_DEFAULTSIZE

        ## py.ico went away in python 2.5, load from executable instead
        this_app=win32api.GetModuleHandle(None)
        try:
            wc.hIcon=win32gui.LoadIcon(this_app, 1)    ## python.exe and pythonw.exe
        except win32gui.error:
            wc.hIcon=win32gui.LoadIcon(this_app, 135)  ## pythonwin's icon
        try:
            classAtom = win32gui.RegisterClass(wc)
        except win32gui.error, err_info:
            if err_info.winerror!=winerror.ERROR_CLASS_ALREADY_EXISTS:
                raise 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:28,代码来源:win32gui_dialog.py

示例8: _DoCreateIcons

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import error [as 别名]
def _DoCreateIcons(self):
        # Try and find a custom icon
        hinst =  win32api.GetModuleHandle(None)
        iconPathName = os.path.abspath(os.path.join( os.path.split(sys.executable)[0], "pyc.ico" ))
        if not os.path.isfile(iconPathName):
            # Look in DLLs dir, a-la py 2.5
            iconPathName = os.path.abspath(os.path.join( os.path.split(sys.executable)[0], "DLLs", "pyc.ico" ))
        if not os.path.isfile(iconPathName):
            # Look in the source tree.
            iconPathName = os.path.abspath(os.path.join( os.path.split(sys.executable)[0], "..\\PC\\pyc.ico" ))
        if os.path.isfile(iconPathName):
            icon_flags = win32con.LR_LOADFROMFILE | win32con.LR_DEFAULTSIZE
            hicon = win32gui.LoadImage(hinst, iconPathName, win32con.IMAGE_ICON, 0, 0, icon_flags)
        else:
            print "Can't find a Python icon file - using default"
            hicon = win32gui.LoadIcon(0, win32con.IDI_APPLICATION)

        flags = win32gui.NIF_ICON | win32gui.NIF_MESSAGE | win32gui.NIF_TIP
        nid = (self.hwnd, 0, flags, win32con.WM_USER+20, hicon, "Python Demo")
        try:
            win32gui.Shell_NotifyIcon(win32gui.NIM_ADD, nid)
        except win32gui.error:
            # This is common when windows is starting, and this code is hit
            # before the taskbar has been created.
            print "Failed to add the taskbar icon - is explorer running?"
            # but keep running anyway - when explorer starts, we get the
            # TaskbarCreated message. 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:29,代码来源:win32gui_taskbar.py

示例9: snapshot

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import error [as 别名]
def snapshot(self, filename="tmp.png"):
        """
        Take a screenshot and save it to `tmp.png` filename by default

        Args:
            filename: name of file where to store the screenshot

        Returns:
            display the screenshot

        """
        if not filename:
            filename = "tmp.png"
        if self.handle:
            try:
                screenshot(filename, self.handle)
            except win32gui.error:
                self.handle = None
                screenshot(filename)
        else:
            screenshot(filename)

        img = aircv.imread(filename)
        os.remove(filename)

        return img 
开发者ID:AirtestProject,项目名称:Airtest,代码行数:28,代码来源:win_ide.py

示例10: dumpWindow

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import error [as 别名]
def dumpWindow(hwnd):
    '''Dump all controls from a window into a nested list
    
    Useful during development, allowing to you discover the structure of the
    contents of a window, showing the text and class of all contained controls.

    Parameters
    ----------
    hwnd
        The window handle of the top level window to dump.

    Returns
    -------
    A nested list of controls. Each entry consists of the
    control's hwnd, its text, its class, and its sub-controls, if any.

    Usage example::
        
        replaceDialog = findTopWindow(wantedText='Replace')
        pprint.pprint(dumpWindow(replaceDialog))
    '''
    windows = []
    try:
        win32gui.EnumChildWindows(hwnd, _windowEnumerationHandler, windows)
    except win32gui.error:
        # No child windows
        return
    windows = [list(window) for window in windows]
    for window in windows:
        childHwnd, windowText, windowClass = window
        window_content = dumpWindow(childHwnd)
        if window_content:
            window.append(window_content)
    return windows 
开发者ID:bluestinger,项目名称:PyAutoTrading,代码行数:36,代码来源:winguiauto.py

示例11: _get_pageant_window_object

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import error [as 别名]
def _get_pageant_window_object():
    if _has_win32all:
        try:
            hwnd = win32gui.FindWindow('Pageant', 'Pageant')
            return hwnd
        except win32gui.error:
            pass
    elif _has_ctypes:
        # Return 0 if there is no Pageant window.
        return ctypes.windll.user32.FindWindowA('Pageant', 'Pageant')
    return None 
开发者ID:iopsgroup,项目名称:imoocc,代码行数:13,代码来源:win_pageant.py

示例12: OnTaskbarNotify

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import error [as 别名]
def OnTaskbarNotify(self, hwnd, msg, wparam, lparam):
        """Receive click events from the taskbar."""
        
        #Left click
        if lparam==win32con.WM_LBUTTONUP:
            pass
            
        #Double click (bring to front)
        elif lparam==win32con.WM_LBUTTONDBLCLK:
            
            always_bring_to_front = True
            
            if always_bring_to_front or self.console_hwnd is not None and self.console_hwnd.minimised:
                self.logger.info('Double click to bring window to foreground.')
                self.bring_to_front()
            else:
                self.logger.info('Double click to minimise window.')
                self.minimise_to_tray()
        
        #Right click (load menu)
        elif lparam==win32con.WM_RBUTTONUP:
            self.logger.info('Right click to open menu.')

            for func in self._commands['OnMenuOpen']:
                self.logger.debug('Called "%s" after opening menu.', func.__name__)
                func(self)
            
            #Occasionally the menu may fail to load for some reason, so skip
            try:
                self.show_menu()
            except pywintypes.error:
                return 0
                
            for func in self._commands['OnMenuClose']:
                self.logger.debug('Called "%s" after closing menu.', func.__name__)
                func(self)
        return 1 
开发者ID:Peter92,项目名称:MouseTracks,代码行数:39,代码来源:tray.py

示例13: _set_icon

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import error [as 别名]
def _set_icon(self, icon_path=None):
        """Load the tray icon.

        Doesn't appear to be editable once it's been set.
        TODO: Look at http://www.brunningonline.net/simon/blog/archives/SysTrayIcon.py.html on how to edit it.
        """

        #Load icon as an image
        try:
            if icon_path is None or not os.path.isfile(icon_path):
                raise TypeError
            icon_flags = win32con.LR_LOADFROMFILE | win32con.LR_DEFAULTSIZE
            hinst = win32api.GetModuleHandle(None)
            hicon = win32gui.LoadImage(hinst, icon_path, win32con.IMAGE_ICON, 0, 0, icon_flags)
        
        #Fallback to default windows icon
        except TypeError:
            hicon = win32gui.LoadIcon(0, win32con.IDI_APPLICATION)
        
        flags = win32gui.NIF_ICON | win32gui.NIF_MESSAGE | win32gui.NIF_TIP
        nid = (self.hwnd, 0, flags, TRAY_EVENT, hicon, self.program_name)
        try:
            win32gui.Shell_NotifyIcon(win32gui.NIM_ADD, nid)
        except win32gui.error:
            # This is common when windows is starting, and this code is hit
            # before the taskbar has been created.
            # but keep running anyway - when explorer starts, we get the
            # TaskbarCreated message.
            pass

        self.logger.debug('Set tray icon.') 
开发者ID:Peter92,项目名称:MouseTracks,代码行数:33,代码来源:tray.py

示例14: _create_menu

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import error [as 别名]
def _create_menu(self, menu, menu_options):
        """Generate the popup menu just before drawing.
        This is needed as it recursively runs on submenus.
        """
        
        for menu_option in menu_options[::-1]:
            if menu_option.get('hidden', False):
                continue
        
            text = menu_option.get('name', 'Option')
            icon = menu_option.get('icon', None)
            action = menu_option.get('action', None)
            id = menu_option.get('_id')
            
            #Set icon
            if icon:
                try:
                    icon = self._set_icon_menu(icon)
                except pywintypes.error:
                    icon = None
            
            #Add menu item
            if id in self.menu_actions_by_id or action is None:                
                item, extras = win32gui_struct.PackMENUITEMINFO(text=text,
                                                                hbmpItem=icon,
                                                                wID=id)
                win32gui.InsertMenuItem(menu, 0, 1, item)
            
            #Add submenu
            else:
                submenu = win32gui.CreatePopupMenu()
                self._create_menu(submenu, action)
                item, extras = win32gui_struct.PackMENUITEMINFO(text=text,
                                                                hbmpItem=icon,
                                                                hSubMenu=submenu)
                win32gui.InsertMenuItem(menu, 0, 1, item) 
开发者ID:Peter92,项目名称:MouseTracks,代码行数:38,代码来源:tray.py

示例15: _RegisterWndClass

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import error [as 别名]
def _RegisterWndClass(self):
        message_map = {}
        wc = win32gui.WNDCLASS()
        wc.SetDialogProc()  # Make it a dialog class.
        wc.hInstance = self.hinst
        wc.lpszClassName = self.className
        wc.style = win32con.CS_VREDRAW | win32con.CS_HREDRAW
        wc.hCursor = win32gui.LoadCursor(0, win32con.IDC_ARROW)
        wc.hbrBackground = win32con.COLOR_WINDOW + 1
        wc.lpfnWndProc = message_map    # could also specify a wndproc.

        # C code: wc.cbWndExtra = DLGWINDOWEXTRA + sizeof(HBRUSH) +
        #                         (sizeof(COLORREF));
        wc.cbWndExtra = win32con.DLGWINDOWEXTRA + struct.calcsize("Pi")

        #  py.ico went away in python 2.5, load from executable instead
        this_app = win32api.GetModuleHandle(None)
        try:
            # python.exe and pythonw.exe
            wc.hIcon = win32gui.LoadIcon(this_app, 1)
        except win32gui.error:
            # pythonwin's icon
            wc.hIcon = win32gui.LoadIcon(this_app, 135)
        try:
            self.classAtom = win32gui.RegisterClass(wc)
        except win32gui.error, err_info:
            if err_info.winerror != winerror.ERROR_CLASS_ALREADY_EXISTS:
                raise 
开发者ID:eavatar,项目名称:eavatar-me,代码行数:30,代码来源:simpledialog.py


注:本文中的win32gui.error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。