0

I'm trying to get clipboard data via python ctypes module for Linux . I've searched but i get only for Windows solution . This question is a solution but for Windows -> getting clipboard(in windows). I found a Python module for my situation , module -> pyperclip . But i wondered, could i get the clipboard data only with ctypes module ? Without any extra packeges . Only with fundamentals.

munir.aygun
  • 414
  • 1
  • 4
  • 11

1 Answers1

0

Well, you should just use pyperclip, which just solves the clipboard problem in a crossplatform way.

For Linux, though, it just tries to use the clipboard from GTK, Qt as it sees fit, or from x11 using an external process - (source code for pyperclip)

If you really want to get the values or set the clipboard in process and directly for x11, you can try to use Python-xlib bindings https://github.com/python-xlib/python-xlib - they do the ctypes part for you, and then check this document which details how to access the clipboard properly.

jsbueno
  • 99,910
  • 10
  • 151
  • 209