クリップボード(サーバー&クライアント)漢字
testCLIP.py
import win32clipboard as w32c
import time
def monitor(interval_sec, onchange):
pre_seq = None
def read():
try:
w32c.OpenClipboard()
return w32c.GetClipboardData()
except Exception as ex:
return ex
finally:
w32c.CloseClipboard()
while True:
seq = w32c.GetClipboardSequenceNumber()
if pre_seq != seq:
data = read()
pre_seq = seq
onchange(data)
time.sleep(interval_sec)
def main():
def onchange(data):
if isinstance(data, Exception):
print("Failed:", data)
else:
print("Clipboard:", data)
if data.find("\\u") != -1:
data2= data.encode('ascii').decode('unicode-escape')
import pyperclip
pyperclip.copy(data2)
monitor(1, onchange)
if __name__ == "__main__":
import pyperclip
main()
"""
s = 'あいうえお'
b = s.encode('unicode-escape').decode('ascii')
# //b = s.encode('ascii').decode('ascii')
pyperclip.copy( b )
print(b)
"""
# //text = '\\u30a8\\u30b9'
# //b = text.encode('ascii').decode('unicode-escape')
# //b = text.encode('ascii')
# //pyperclip.copy( b )
0 件のコメント:
コメントを投稿