0

Im used pynput library for press keys and add text to the active window, it's works:

from pynput.keyboard import Key, Controller

keyboard = Controller()
keyboard.press('a')
keyboard.press(Key.enter)

But i cant execute combinations ctrl+c or ctrl+v

1 Answer 1

3

you can use the keyboard module instead:

it can be installed with:

pip install keyboard

here is the code if you want to use it:

import keyboard,time
print("Select text you want to copy...")
time.sleep(1)

keyboard.press("ctrl+c")
print("ctr+c pressed...")
print("go to a place you would like to paste on")

time.sleep(1)
keyboard.press("ctrl+v")
print("ctrl-v successfully pressed...")
print("Program finished with status 0\nPress enter to exit...",end='')
input()
Sign up to request clarification or add additional context in comments.

5 Comments

ctrl + c not works(
for me it works... strange
just for me script don't copy text, but enter text with ctrl + v hmmmm
when the program runs it gives you 1 second to select the text, and 1 second to go to the page you want to paste into.
im understand that,ctrl + c combination not works for me, thank you maybe your answer will help someone

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.