R
R
Ridalit2021-07-25 09:46:30
Python
Ridalit, 2021-07-25 09:46:30

How to write text to windows buffer with a space in front of it?

To fill the buffer I use:

import pyperclip

pyperclip.copy("Типа текст")


But I need that when I click "insert" it would be displayed not "Type text", but " Type text"
That is, at the beginning you need a space

import pyperclip

pyperclip.copy("  Типа текст")


or

import pyperclip
pyperclip.copy("   "+"Типа текст")

do not work, the space is simply erased.

I must say right away that for my task it will not work to use anything like:

import pyperclip
import pyautogui

pyautogui.write("   ")
pyperclip.copy("Типа текст")

You need to write text to the buffer already with a space

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
soremix, 2021-07-25
@SoreMix

Everything is working. The space can be trimmed by the program into which you insert the line

O
o5a, 2021-07-25
@o5a

The problem seems to be in the rest of the code or the way you then try to read the clipboard.
Just check

pyperclip.copy(" тест")
print(pyperclip.paste())

and you will see that the space is buffered.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question