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


Python Dispatch.bgColor方法代码示例

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


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

示例1: TestObjectFromWindow

# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import bgColor [as 别名]
def TestObjectFromWindow():
    # Check we can use ObjectFromLresult to get the COM object from the
    # HWND - see KB Q249232
    # Locating the HWND is different than the KB says...
    hwnd = win32gui.FindWindow('IEFrame', None)
    for child_class in ['TabWindowClass', 'Shell DocObject View',
                        'Internet Explorer_Server']:
        hwnd = win32gui.FindWindowEx(hwnd, 0, child_class, None)
        assert hwnd, "Couldn't find '%s'" % (child_class,)
    # But here is the point - once you have an 'Internet Explorer_Server',
    # you can send a message and use ObjectFromLresult to get it back.
    msg = win32gui.RegisterWindowMessage("WM_HTML_GETOBJECT")
    rc, result = win32gui.SendMessageTimeout(hwnd, msg, 0, 0, win32con.SMTO_ABORTIFHUNG, 1000)
    ob = pythoncom.ObjectFromLresult(result, pythoncom.IID_IDispatch, 0)
    doc = Dispatch(ob)
    # just to prove it works, set the background color of the document.
    for color in "red green blue orange white".split():
        doc.bgColor = color
        time.sleep(0.2)
开发者ID:Einstein-NTE,项目名称:einstein,代码行数:21,代码来源:testExplorer.py

示例2: TestObjectFromWindow

# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import bgColor [as 别名]
def TestObjectFromWindow():
    # Check we can use ObjectFromLresult to get the COM object from the
    # HWND - see KB Q249232
    # Locating the HWND is different than the KB says...
    hwnd = win32gui.FindWindow("IEFrame", None)
    for child_class in ["TabWindowClass", "Shell DocObject View", "Internet Explorer_Server"]:
        hwnd = win32gui.FindWindowEx(hwnd, 0, child_class, None)
        # ack - not working for markh on vista with IE8 (or maybe it is the
        # lack of the 'accessibility' components mentioned in Q249232)
        # either way - not working!
        return
    # But here is the point - once you have an 'Internet Explorer_Server',
    # you can send a message and use ObjectFromLresult to get it back.
    msg = win32gui.RegisterWindowMessage("WM_HTML_GETOBJECT")
    rc, result = win32gui.SendMessageTimeout(hwnd, msg, 0, 0, win32con.SMTO_ABORTIFHUNG, 1000)
    ob = pythoncom.ObjectFromLresult(result, pythoncom.IID_IDispatch, 0)
    doc = Dispatch(ob)
    # just to prove it works, set the background color of the document.
    for color in "red green blue orange white".split():
        doc.bgColor = color
        time.sleep(0.2)
开发者ID:hitej,项目名称:meta-core,代码行数:23,代码来源:testExplorer.py


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