0

Hey everyone this code doesn't work for me:

import pyperclip as clip
string="blah blah"
clip.copy(string)
clip.paste(string)

the error:

TypeError: init_windows_clipboard.<locals>.paste_windows() takes 0 positional arguments but 1 was given

THANKS

Arian
  • 57
  • 9

1 Answers1

1

Try running the code after removing the argument from clip.paste().

import pyperclip as clip
string="blah blah"
clip.copy(string)
clip.paste()
Ritik Raj
  • 56
  • 3
  • Can I ask you another question? I tried using it for pasting a text in a textbox but I it doesn't paste it and it gives me no error anymore...do you know what is the problem??? – Arian Jul 24 '22 at 16:07
  • I think you are not understanding what clip.paste() is doing, it actually return the word present in the clipboard (here string is sent to the clipboard) . x = clip.paste() , x will contain the word "blah blah" . Now , in order to paste it in a textbox , you just need to press ctrl+V. – Ritik Raj Jul 24 '22 at 16:18
  • Thanks...So can you give me a way please to do a paste action in python in a textboxt? – Arian Jul 24 '22 at 16:36
  • which textbox are you talking about ? – Ritik Raj Jul 24 '22 at 16:38
  • Any text box like entry in tkinter – Arian Jul 24 '22 at 16:39
  • okay for that, first you need to make that entry active, and then use pyautogui module to simulate keystrokes ctrl+v. when ctrl+v is pressed by pyautogui then it will paste the content wherever the cursor is present currently, and since you have made the entry widget active so the cursor is present there, this will paste the text in that entry widget. – Ritik Raj Jul 24 '22 at 16:43
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/246716/discussion-between-arian-and-ritik-raj). – Arian Jul 24 '22 at 16:46