So, I'm running a script from the Command Prompt with elevated permissions (Python3).
It runs perfectly for a time. But after about 10 minutes, it times out with this error:
Traceback (most recent call last):
File "C:\Users\xxxxx\Desktop\clicker\ClickerImprovedV3.py", line 200, in <module>
PyDeepClip1 = pyperclip.paste()
File "C:\Users\thesu\AppData\Local\Programs\Python\Python39\lib\site-packages\pyperclip\__init__.py", line 490, in paste_windows
with clipboard(None):
File "C:\Users\thesu\AppData\Local\Programs\Python\Python39\lib\contextlib.py", line 117, in __enter__
return next(self.gen)
File "C:\Users\thesu\AppData\Local\Programs\Python\Python39\lib\site-packages\pyperclip\__init__.py", line 452, in clipboard
raise PyperclipWindowsException("Error calling OpenClipboard")
pyperclip.PyperclipWindowsException: Error calling OpenClipboard ([WinError 5] Access is denied.)
So, basically, this is a recursive program to automate the boring stuff. I copy from 1 spot, paste to another online. It spits out its data. I grab that data, copy it, go back to the spreadsheet, then paste it into there.
As I said before, the program runs perfectly fine.
It seems to me that, after a certain time (I'm not exactly sure how much, because the program runs without me there :-) that somehow the clipboard locks... or empties?! I thought that running this with Admin privilages would solve this from looking at other answers.
A couple of things that may or may not have anything to do with this.
- When this program was at its simplest, this didn't happen. Still using pyautogui and pyperclip.
- I made a lot of changes in the code to catch errors as they've been popping up. This error seems to be ONLY after I started using pyperclip.paste() to catch a variable and make sure that the clipboard pasting INTO the website, and the clipboard pasting FROM the website were different.
- Before this error started showing, I was just using
pg.hotkey('ctrl', 'a')
pg.hotkey('ctrl', 'v')
and it would run for hours, ableit, with some problems. Which is why I changed it.
- Is there something that I need to be doing to flush the clipboard? Am I making too many calls to it somehow?