← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #248307]: put RTF formated data into clipboard

 

Question #248307 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/248307

    Status: Open => Solved

Vyacheslav Kolesnik confirmed that the question is solved:
Here is a codefix what doing what I need:

def putRTFStringToClipboard(rtf_str):
    from java.awt.datatransfer import StringSelection
    from java.awt.datatransfer import Clipboard
    from javax.activation import DataHandler
    from java.awt import Toolkit
    from java.lang import String
    from java.nio import ByteBuffer
    from java.lang import StringBuffer
    from java.io import InputStream, ByteArrayInputStream 
    cb = Toolkit.getDefaultToolkit().getSystemClipboard()
    cb_data = map(ord, rtf_str)    
    ba = ByteArrayInputStream(cb_data)
    cb.setContents(DataHandler(ba,"text/rtf"), None)

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.