[Python] Create a program to delete line breaks in the clipboard + Register as a shortcut with windows


How to delete line breaks when copying and pasting PDF

Write code

import pyperclip

s = pyperclip.paste()
s = s.replace("\n", "")
s = s.replace("\r", "")

Introduce a module called pyperclip to operate the clipboard. Get the clipboard with pyperclip.paste (). Remove line feed code using replace (). If it is inconvenient if there are two types of characters to delete, " \ r " " \ n ", adjust accordingly. Paste it to the clipboard with pyperclip.copy ().

I also tried using pyautogui to automatically paste, but it wasn't useful because the execution speed was more than doubled. He said that he only needed to be able to operate the clipboard.


Convert to executable using pyinstaller. Install from the command prompt.

pip install pyinstaller

Then type the following command to execute it.

pyinstaller filename--onefile

An exe file is created in the dist folder.

Register to shortcut key

Reference: How to start the program quickly (set a shortcut key)

That's it. If it doesn't work with the registered key, restart it once.

the end

Achieve the goal by registering with the macro button of the mouse. It took about 3 seconds to complete the execution, so the practicality is not so high. In that case, it can be said that the method of predecessor is fine.

After that, if it depends on the external macro function, it is not necessary to complete it with one command separately, so put the shortcut file name as one character and put it in the folder where the path passes → "type win + R, file name, enter It is also ant to register it as a "execute" macro. If anything, you can place it on the taskbar and start it with the shortcut of win + number. There is a theory that these are faster to execute.

There may also be a more normal and efficient way to remove line breaks.

Recommended Posts

[Python] Create a program to delete line breaks in the clipboard + Register as a shortcut with windows
Probably the easiest way to create a pdf with Python3
How to create a heatmap with an arbitrary domain in Python
Read a file in Python with a relative path from the program
Create a compatibility judgment program with the random module of python.
Create a shortcut to run a Python file in VScode on your terminal
I tried to create a program to convert hexadecimal numbers to decimal numbers with python
Steps to create a Python virtual environment with VS Code on Windows
Read the file with python and delete the line breaks [Notes on reading the file]
Create a record with attachments in KINTONE using the Python requests module
I made a program to check the size of a file in Python
What is the fastest way to create a reverse dictionary in python?
[Python / Jupyter] Translate the comment of the program copied to the clipboard and insert it in a new cell
[Python] Get the files in a folder with Python
Create a LINE BOT with Minette for Python
I want to create a window in Python
How to create a JSON file in Python
Create a virtual environment with conda in Python
Steps to create a Twitter bot with python
Create a new page in confluence with Python
Various ways to read the last line of a csv file in Python
[Python] Created a class to play sin waves in the background with pyaudio
Zip-compress any file with the [shell] command to create a file and delete the original file.
SSH login to the target server from Windows with a click of a shortcut
How to get a list of files in the same directory with python
(Diary 1) How to create, reference, and register data in the SQL database of Microsoft Azure service with python
Run the output code with tkinter, saying "A, pretending to be B" in python
How to convert / restore a string with [] in python
Specify a subcommand as a command line argument in Python
How to create a submenu with the [Blender] plugin
[LINE Messaging API] Create a rich menu in Python
How to identify the element with the smallest number of characters in a Python list?
Create an exe file that works in a Windows environment without Python with PyInstaller
Create a plugin to run Python Doctest in Vim (2)
Try embedding Python in a C ++ program with pybind11
Create a plugin to run Python Doctest in Vim (1)
Convert the image in .zip to PDF with Python
I want to work with a robot in python.
From buying a computer to running a program with python
Output a character string with line breaks in PyYAML
Explaining how to make LINE BOT in the world's easiest way (2) [Preparing a bot application in a local environment with Django in Python]
Specify MinGW as the compiler to use with Python
A program to write Lattice Hinge with Rhinoceros with Python
Try to create a waveform (audio spectrum) that moves according to the sound with python
[Python] How to create a 2D histogram with Matplotlib
[Python] Create a Tkinter program distribution file with cx_Freeze
A note that runs an external program in Python and parses the resulting line
Create a fake Minecraft server in Python with Quarry
How to use python multiprocessing (continued 3) apply_async in class with Pool as a member
[Python] If you create a file with the same name as the module to be imported, an Attribute Error will occur.
Run the program without building a Python environment! !! (How to get started with Google Colaboratory)
I made a class to get the analysis result by MeCab in ndarray with python
A script that makes it easy to create rich menus with the LINE Messaging API
A program that automatically resizes the iOS app icon to the required image size in Python
Recursively get the Excel list in a specific folder with python and write it to Excel.
I made a program to collect images in tweets that I liked on twitter with Python
I tried to create a Python script to get the value of a cell in Microsoft Excel
Let's create a program that automatically registers ID/PW from CSV to Bitwarden with Python + Selenium
A program that failed when trying to create a linebot with reference to "Dialogue system made with python"
I also tried to imitate the function monad and State monad with a generator in Python
I wrote a doctest in "I tried to simulate the probability of a bingo game with Python"