win32clipboard operation

LeeRisq leerisq at gmail.com
Thu Jul 23 17:33:39 CEST 2009


Hi all,

Newbie question. I've written a script that outputs to a text file.

Now, I just want to copy the content to win32clipboard for access to
other applications. Here's the mess I've come up with so far:)

import xlrd
import win32clipboard



def program_uno():
    ofile = open(r"C:\Query\DQL.txt", "w")
    book = xlrd.open_workbook("C:\DocLoader\MCL_Drawing and Legacy
Docloader Sheet.xls")
    sh = book.sheet_by_index(0)
    e = sh.cell_value(1, 0)
    a = sh.col_values(0, start_rowx=2, end_rowx=200)
    b = r'%' + e
    c = r'%Draft%'
    y = r"some text..." %(b, c)
    w = r"some more text..."
    ofile.writelines(y)
    for x in a:
        d = r'%' + x
        z = r" loop text..." %(d, c)
        f = ofile.writelines(z)
    ofile.writelines(w)


def copy_text():
    ifile = open(r"C:\Query\DQL.txt", "r")


    win32clipboard.OpenClipboard(0)
    win32clipboard.EmptyClipboard()
    win32clipboard.SetClipboardText()
    win32clipboard.CloseClipboard

program_uno()
copy_text()



More information about the Python-list mailing list