I have code that displays the contents of a buffer without stopping. And I need to display this only when the buffer changes. Help friends
import win32clipboard
import threading
import time
def clipboard():
while True:
win32clipboard.OpenClipboard()
data = win32clipboard.GetClipboardData()
win32clipboard.CloseClipboard()
time.sleep(0.33)
print(data)
clipboard = threading.Thread(target=clipboard)
clipboard.start()
Modified your clipboard()
function. Hope this works.
import win32clipboard
import threading
import time
def clipboard():
prev_data = None
while True:
win32clipboard.OpenClipboard()
data = win32clipboard.GetClipboardData()
win32clipboard.CloseClipboard()
time.sleep(0.33)
if data != prev_data:
print(data)
prev_data = data
clipboard = threading.Thread(target=clipboard)
clipboard.start()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.