首页 > 代码库 > python 中调用windows系统api操作剪贴版

python 中调用windows系统api操作剪贴版

# -*- coding: utf-8 -*-‘‘‘Created on 2013-11-26@author: Chengshaoling‘‘‘import win32clipboard as w32import win32conclass OperateClipboard(object):        def __init__(self):        # print "OperateClipboard"        pass        def getText(self):        w32.OpenClipboard()        #d = w32.GetClipboardData(win32con.CF_TEXT) #默认字符编码,复制粘贴时中文会出现乱码        d = w32.GetClipboardData(win32con.CF_UNICODETEXT)#指定编码为unicode,复制粘贴时中文不会会出现乱码        w32.CloseClipboard()        return d        def setText(self,aString):        print "aString=",aString        w32.OpenClipboard()        w32.EmptyClipboard()        #w32.SetClipboardData(win32con.CF_TEXT, aString)#默认字符编码,复制粘贴时中文会出现乱码        w32.SetClipboardData(win32con.CF_UNICODETEXT,aString)#指定编码为unicode,复制粘贴时中文不会会出现乱码        w32.CloseClipboard()       if __name__ == "__main__":    opcb = OperateClipboard()    opcb.setText("test1111")    txt = opcb.getText()    print txt    pass

http://blog.sina.com.cn/s/articlelist_1408246567_0_1.html