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


Python win32clipboard.SetClipboardData方法代码示例

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


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

示例1: OnEditCopyCode

# 需要导入模块: import win32clipboard [as 别名]
# 或者: from win32clipboard import SetClipboardData [as 别名]
def OnEditCopyCode(self, command, code):
		""" Sanitizes code from interactive window, removing prompts and output,
			and inserts it in the clipboard."""
		code=self.GetSelText()
		lines=code.splitlines()
		out_lines=[]
		for line in lines:
			if line.startswith(sys.ps1):
				line=line[len(sys.ps1):]
				out_lines.append(line)
			elif line.startswith(sys.ps2):
				line=line[len(sys.ps2):]
				out_lines.append(line)
		out_code=os.linesep.join(out_lines)
		win32clipboard.OpenClipboard()
		try:
			win32clipboard.SetClipboardData(win32clipboard.CF_UNICODETEXT, unicode(out_code))
		finally:
			win32clipboard.CloseClipboard() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:21,代码来源:interact.py

示例2: copy_to_system

# 需要导入模块: import win32clipboard [as 别名]
# 或者: from win32clipboard import SetClipboardData [as 别名]
def copy_to_system(self, clear=True):
        """
            Copy the contents of this instance into the Windows system
            clipboard.

            Arguments:
             - *clear* (boolean, default: True) -- if true, the Windows
               system clipboard will be cleared before this instance's
               contents are transferred.

        """
        win32clipboard.OpenClipboard()
        try:
            # Clear the system clipboard, if requested.
            if clear:
                win32clipboard.EmptyClipboard()

            # Transfer content to Windows system clipboard.
            for format, content in self._contents.items():
                win32clipboard.SetClipboardData(format, content)

        finally:
            win32clipboard.CloseClipboard() 
开发者ID:dictation-toolbox,项目名称:dragonfly,代码行数:25,代码来源:clipboard.py

示例3: testWin32ToCom

# 需要导入模块: import win32clipboard [as 别名]
# 或者: from win32clipboard import SetClipboardData [as 别名]
def testWin32ToCom(self):
        # Set the data via the std win32 clipboard functions.
        val = str2bytes("Hello again!") # ensure always bytes, even in py3k
        win32clipboard.OpenClipboard()
        win32clipboard.SetClipboardData(win32con.CF_TEXT, val)
        win32clipboard.CloseClipboard()
        # and get it via an IDataObject provided by COM
        do = pythoncom.OleGetClipboard()
        cf = win32con.CF_TEXT, None, pythoncom.DVASPECT_CONTENT, -1, pythoncom.TYMED_HGLOBAL
        stg = do.GetData(cf)
        got = stg.data
        # The data we get back has the \0, as our STGMEDIUM has no way of 
        # knowing if it meant to be a string, or a binary buffer, so
        # it must return it too.
        self.failUnlessEqual(got, str2bytes("Hello again!\0")) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:17,代码来源:testClipboard.py

示例4: set_system_text

# 需要导入模块: import win32clipboard [as 别名]
# 或者: from win32clipboard import SetClipboardData [as 别名]
def set_system_text(cls, content):
        content = text_type(content)
        win32clipboard.OpenClipboard()
        try:
            win32clipboard.EmptyClipboard()
            win32clipboard.SetClipboardData(cls.format_unicode, content)
        finally:
            win32clipboard.CloseClipboard() 
开发者ID:dictation-toolbox,项目名称:dragonfly,代码行数:10,代码来源:clipboard.py

示例5: set_system_text

# 需要导入模块: import win32clipboard [as 别名]
# 或者: from win32clipboard import SetClipboardData [as 别名]
def set_system_text(cls, content):
        content = unicode(content)
        win32clipboard.OpenClipboard()
        try:
            win32clipboard.EmptyClipboard()
            win32clipboard.SetClipboardData(cls.format_unicode, content)
        finally:
            win32clipboard.CloseClipboard()


    #----------------------------------------------------------------------- 
开发者ID:t4ngo,项目名称:dragonfly,代码行数:13,代码来源:clipboard.py

示例6: setClipboardData

# 需要导入模块: import win32clipboard [as 别名]
# 或者: from win32clipboard import SetClipboardData [as 别名]
def setClipboardData(data): # “ Václav
        win32clipboard.EmptyClipboard()
        win32clipboard.SetClipboardData(win32clipboard.CF_UNICODETEXT,
            data) 
开发者ID:ActiveState,项目名称:code,代码行数:6,代码来源:recipe-576887.py

示例7: main

# 需要导入模块: import win32clipboard [as 别名]
# 或者: from win32clipboard import SetClipboardData [as 别名]
def main(host=None, port=None, serial=None, scale=1.0, out='screenshot.png', method='minicap'):
    """
    If minicap not avaliable then use uiautomator instead

    Disable scale for now.
    Because -s scale is conflict of -s serial
    """
    print('Started screencap')
    start = time.time()

    client = adbkit.Client(host=host, port=port)
    device = client.device(serial)
    im = device.screenshot(scale=scale)
    im.save(out)
    print('Time spend: %.2fs' % (time.time() - start))
    print('File saved to "%s"' % out)

    try:
        import win32clipboard

        output = StringIO()
        im.convert("RGB").save(output, "BMP")
        data = output.getvalue()[14:]
        output.close()

        win32clipboard.OpenClipboard()
        win32clipboard.EmptyClipboard()
        win32clipboard.SetClipboardData(win32clipboard.CF_DIB, data)
        win32clipboard.CloseClipboard()
        print('Copied to clipboard')
    except:
        pass # ignore 
开发者ID:NetEaseGame,项目名称:ATX,代码行数:34,代码来源:screencap.py

示例8: _PutTextAndHtmlToClipboard

# 需要导入模块: import win32clipboard [as 别名]
# 或者: from win32clipboard import SetClipboardData [as 别名]
def _PutTextAndHtmlToClipboard(self, txt, fragment):
        """
        Put the given text and html into the windows clipboard.

        The html will be written in accordance with strange "HTML Format" as specified
        in http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/dataexchange/clipboard/htmlclipboardformat.asp
        """
        import win32clipboard

        MARKER_BLOCK_OUTPUT = \
            "Version:1.0\r\n" \
            "StartHTML:%09d\r\n" \
            "EndHTML:%09d\r\n" \
            "StartFragment:%09d\r\n" \
            "EndFragment:%09d\r\n" \
            "StartSelection:%09d\r\n" \
            "EndSelection:%09d\r\n" \
            "SourceURL:%s\r\n"

        DEFAULT_HTML_BODY = \
            "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">" \
            "<HTML><HEAD></HEAD><BODY><!--StartFragment-->%s<!--EndFragment--></BODY></HTML>"

        html = DEFAULT_HTML_BODY % fragment
        source = "http://objectlistview.sourceforge.net/python"

        fragmentStart = selectionStart = html.index(fragment)
        fragmentEnd = selectionEnd = fragmentStart + len(fragment)

        # How long is the prefix going to be?
        dummyPrefix = MARKER_BLOCK_OUTPUT % (0, 0, 0, 0, 0, 0, source)
        lenPrefix = len(dummyPrefix)

        prefix = MARKER_BLOCK_OUTPUT % (lenPrefix, len(html)+lenPrefix,
                        fragmentStart+lenPrefix, fragmentEnd+lenPrefix,
                        selectionStart+lenPrefix, selectionEnd+lenPrefix,
                        source)
        htmlForClipboard = (prefix + html)

        try:
            win32clipboard.OpenClipboard(0)
            win32clipboard.EmptyClipboard()
            cfText = 1
            win32clipboard.SetClipboardData(cfText, txt)
            cfHtml = win32clipboard.RegisterClipboardFormat("HTML Format")
            win32clipboard.SetClipboardData(cfHtml, htmlForClipboard)
        finally:
            win32clipboard.CloseClipboard() 
开发者ID:JackonYang,项目名称:bookhub,代码行数:50,代码来源:ObjectListView.py


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