I am writing a python script that prepares a number of pieces of data to be posted into a web page and copies them to the clipboard using pyperclip. Currently I just have a time.sleep() statement between each one but based on latency and some slight variations in the web page response there may be other actions to be carried out (e.g. scroll down, clear a modal etc) before I am ready to paste the data. I run the risk of sometimes missing my 'window' for the paste but most of the time I am waiting for the sleep to finish and update the clipboard.
Instead of a fixed time period, it would be useful if I could make the python script pause until it detects the paste function and then load the clipboard with the next piece of data.
Note that the Ctrl+V will occur with the browser window having focus rather than the python script in case that makes a difference
I am using Chrome on Win-11 so an OS specific solution is fine for me. Also it does not need to be the Ctrl+V function (although this makes the most logical sense); any other trigger will do as long as it can't be confused and I can use pyautogui.keydown, keypress, keyup to trigger the Ctrl+V
Current Code:
pyperclip.copy(EventTitle)
os.system('cls')
print('Title: ' + EventTitle)
time.sleep(8)
os.system('cls')
pyperclip.copy(EventDescription)
print('Description: \n\n' + EventDescription)
time.sleep(8)
os.system('cls')
basically I want to replace the time.sleep() with {wait for paste command}