# -*- coding: utf-8 -*-

import win32clipboard as wc
import win32con
import sys



def getCopyText():
    wc.OpenClipboard()
    try:
        copy_text = wc.GetClipboardData(win32con.CF_TEXT)
        wc.CloseClipboard()
        return copy_text
    except TypeError:
        return "Target Copied Binary."

result = getCopyText()
if len(sys.argv) == 2 and sys.argv[1] == "-f":
    with open("CopyText.txt",'a') as  copy:
        copy.write(result)
else:
    #import chardet
    #print chardet.detect(getCopyText())   # 找到包含中文内容的字符串编码
    print result#.decode('GB2312')  # 转码

发表评论

电子邮件地址不会被公开。 必填项已用*标注