3

Autokey function, text = clipboard.get_selection(), which clipboard is the selected data is stored?

I am using Linux Mint 19.1 Cinnamon with Python 3.6. I am searching for the clipboard storage of Autokey's (Python 3) function, text = clipboard.get_selection().

I assume that it is stored in one of the X clipboard's three clipboards, but none of the Gnome compatible clipboard viewers display it.

I need to know how to refer to the particular clipboard in an Autokey, (or Python), script, to view the data before and after it is being altered by a script.

Paste this code in an Autokey3 keyboard macro. (script) and use any key definition to activate it.

In Linux (or any X11 app), the clipboard owner process must be running to # be able to paste the clipboard contents?

Select any text.

import time
import subprocess
import sys

t_xt = ""
keyboard.send_keys("<ctrl>+a")   #  select all
time.sleep(.3)                   #  delay of .3 of a second
t_xt = clipboard.get_selection    #  place selection in clipboard

time.sleep(.3)

keyboard.send_keys(t_xt)         #  retrieves the t_xt I want to know where this is stored and how I can refer it in an Autokey script?
keyboard.send_keys("<ctrl>+a") #  This pastes the contents of a different clipboard.

sys.exit()
SL5net
  • 1,446
  • 3
  • 15
  • 32
ineuw
  • 65
  • 7

1 Answers1

3

According to this documentation, it uses the X mouse selection clipboard.

BlueDrink9
  • 221
  • 1
  • 11
  • Thanks for the link. Much appreciated. – ineuw Nov 25 '19 at 02:05
  • 2
    Some of the docs look a little outdated, so if you finish experimenting and find that is isn't actually that clipboard, please update your question to reflect that! – BlueDrink9 Nov 25 '19 at 05:48
  • 1
    Unfortunately, there are two active clipboards in Linux. Several websites mention them and offer explanations, but no sample code. So, I don't know how to refer to either one to print or display the contents. The only thing I found is how to direct xsel to clean each board import subprocess # CLIPBOARD cleaner subprocess.run(["xsel","-bc"]) # PRIMARY cleaner subprocess.run(["xsel","-c"]) – ineuw Nov 26 '19 at 06:16
  • 1
    @ineuw don't forget to accept this as an answer if it answered the question you asked, to prevent this question from staying in the 'open questions' section of the site – BlueDrink9 Oct 11 '20 at 22:10
  • 1
    Finally found a very clear explanation that PRIMARY - This is normally used for middle mouse button = copy/paste SECONDARY - Normally not used by much, but it exists. Usually as an in app specific copy and paste. CLIPBOARD - Usually Ctrl+c and Ctrl+v style copy and paste. – ineuw Oct 12 '20 at 23:19