spyoungtech/pyclip

Can't see clipboard in combination with other library

Closed this issue · 2 comments

keyboard.press_and_release('ctrl+a')
keyboard.send('ctrl+c')
pyclip.paste(text=True)

If I open notepad and click ctrl+v I'll see the text. But pyclip does not see.

Sorry, can't reproduce using notepad. Seems to work for me.

image

I take it back. I was able to reproduce it, but intermittently. The reason for this is that the application takes some time to receive the keystrokes and change the clipboard. If you add a small sleep between send('ctrl+c') and pyclip.paste(text=True) this becomes 100% reliable.

keyboard.press_and_release('ctrl+a')
keyboard.send('ctrl+c')
time.sleep(0.1)
pyclip.paste(text=True)

So, in essence, the problem is you're accessing the clipboard before the contents actually change.