Accessing clipboard through software built on Python

Musatov tomusatov at gmail.com
Sat Oct 27 14:45:47 EDT 2018


On Saturday, October 27, 2018 at 10:28:00 AM UTC-5, Michael Torrie wrote:
> Couple of questions:
> On 10/27/2018 07:17 AM, Musatov wrote:
> > I am wondering if Python could be used to write a program that allows:
> > 
> > 1. Highlight some text
> > 2. Ctl+HOTKEY1 stores the string of text somewhere as COPIEDTEXT1
> 
> This text comes from where?  Another application?
>From a webpage.
> 
> > 3. Highlight another string of text
> > 4. Ctl+HOTKEY1 stores another string of text somewhere as COPIEDTEXT2
> > 
> > THEN
> > 
> > 5. Ctl+HOTKEY2 pastes COPIEDTEXT1
> 
> Gets pasted where?
Unto a savable field on another webpage.
> 
> > 6. Ctl+HOTKEY2 pastes COPIEDTEXT2
> 
> As far as I know it's not possible for an application to directly yank
> highlighted text from another application.  The first application would
> have to first copy that text to the clipboard (Control-C in that app)
> and then the second application could grab it from the clipboard
> (ctrl-hotkey1) and then store it in its own variables.  Ctrl-hotkey2
> could then push the text back into the clipboard and then you can ctrl-V
> paste it in the other application.  This type of functionality is known
> often found in clipboard manager programs.
Yes, I understand but they all involve putting one piece of text unto the clipboard at a time.

I want COPYFIELD1
       COPYFIELD2
       PASTEFIELD1
       PASTEFIELD2

Without having to look at the damn clipboard manager! And no more than two hotkey combinations.

It would make my job so much easier, and easier for many other workers doing the same job.
> 
> > I found "pyperclip" and "Tkinter" but I don't know where to start.
> Here's another file that demonstrates accessing the clipboard on the
> Linux, Mac, and Windows:
> 
> https://github.com/Shizmob/clippy/blob/master/clip.py
Thank you.> 
> As for the hotkey stuff, that's also dependent on the operating system.
> Google for something like "python global hotkey linux" to get an example
> of how to implement that.
Ok



More information about the Python-list mailing list