Please note that there are inevitably many jargon because it contains a lot of relatives (although not exactly).Premise
There are A and B, and A and B are copied alternately. When A is changed, B also changes, but since B sometimes becomes the same, I am trying to make something that does not perform the process x described later when it becomes the same continuously. I was worried for dozens of hours and couldn't do it after all, so I ended up throwing a ball m (_ _) m
import pyperclip as pyc while True: if pyc.paste (). startswith ("a"): copy #A i = pyc.paste () while True: if pyc.paste (). startswith ("b"): copy #B try: try: print (i) # processing x break except: print (traceback.format_exc ()) break else: else: continue else: else: continue
Since A increases one by one, there is a possibility that it can be realized by using it if i am young.
I couldn't put up an image in the reply, so here. I can't explain it to my vocabulary, so make it a gif.
Answer # 1
I watch the clipboard in a loop and keep reading the same value all the time,
Not processing when it is continuous means
Do you want to earn the timing when the contents change?
If you use waitForNewPaste (),
You can block the process until the contents of the clipboard change.
if pyc.paste (). startswith ("a"): copy #A i = pyc.paste ()
If the contents of the clipboard change after checking with startswith
The variable i may not start with "a", so
If you want to be strict, it is better to store it in a variable and then check it with an if statement.
Answer # 2
You may have misunderstood what you want to do, but why not keep the previous value of b and check if it's the same?
import pyperclip as pyc prev_b = None while True: if pyc.paste (). startswith ("a"): copy #A i = pyc.paste () while True: x = pyc.paste () if x.startswith ("b"): try: try: if x! = prev_b: prev_b = x print (i) # processing x break except: print (traceback.format_exc ()) break else: else: continue else: else: continue
- python about iterative processing with specified numbers
- i want to add processing to the python library
- parallel processing using python multiprocessingpool and multiprocessingqueue does not work well
- python:about processing such as timesleep and wxpython
- python iterative processing num is not defend
- python - while syntax processing
- i want to speed up the processing of [python] for
- python - about range and int type processing
- processing using the len function when an integer value is obtained from python standard input
- python 3x - update processing and multi-process with pyqtgraph
- python - problem that processing ends without scraping error
- i want to execute processing like imfill in matlab with python
- python - nested, nested dictionary processing
- python - improved efficiency of loop processing in pandas data frames
- python 3x - i want to perform the same processing for each folder under the specified folder
- python - about multiple processing and loop processing in discordpy
- python - i want to avoid line breaks in the file path
- python - websocket processing using asyncio
- python 3x - i'm not sure about asynchronous processing (asyncio)
- python - you may need to restart the kernel to use updated packages error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- python 3x - typeerror: 'method' object is not subscriptable
- i want to call a child component method from a parent in vuejs
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- xcode - pod install [!] no `podfile 'found in the project directory