0

this is the current code:

import time
import sys
import os

sys.path.append(os.path.abspath("SO_site-packages"))
import pyperclip

recent_value = ""
while True:
    tmp_value = pyperclip.paste()
    if not tmp_value = recent_value:
        recent_value = tmp_value
        print("Value changed: %s" % str(recent_value)[:20])
    time.sleep(0.1)

What I'm trying to do: create a constant loop that waits for a user to copy text to clipboard, and print it whenever that happens.

What happens currently: It only prints out the last copied item and stops.

My question is: How to make this code a listening loop?

Help will be deeply appreciated.

ritiek
  • 2,477
  • 2
  • 18
  • 25
  • Do you get a traceback when it stops? – SiHa Oct 26 '17 at 07:06
  • Your code already seems to be in a listening loop. I can run the script and it does print whenever and whatever text I copy. Am I understanding your question correctly? – ritiek Oct 26 '17 at 07:43
  • It must be how i run it then? I press play on pycharm.. am i missing something? –  Oct 27 '17 at 14:05

0 Answers0