4

Is there a way to read the clipboard with ctypes?

I'm trying to make a program which virtually presses printscreen, grabs the image from the clipboard, and saves it as a variable. I can't use any libraries other than ctypes, pygame, time, random, sys, and os (basically just the libraries included with python).

Can anyone help?

I’m using Windows 10 and Python 3.7 (32 bit).

Edit: The only answer to the question Read text from clipboard in Windows using ctypes doesn't work with pictures.

Is there a way to capture an image of the screen in python with ctypes? is a related question I asked.

object-Object
  • 1,587
  • 1
  • 12
  • 14
  • For images it's a bit trickier, since additional processing is required. You may consider replacing *ctypes* with (external) *pywin32* which has a *Python* friendlier interface. – CristiFati Feb 20 '19 at 18:10
  • I can't use any external libraries because I am using a school computer. My school also blocked command prompt, so I can't use pip either. – object-Object Feb 21 '19 at 02:38
  • There are some complex structures that you'll most likely need to define, so the *ctypes* approach might get generate unusually long code, that has nothing to do with the question per se (like in the other question *argtypes* and *restype* setting). Did you check whether *pywin32* isn't already installed (`import win32api`)? Or maybe *pygame* could have some functionality that could help you? Anyway, how are you supposed to run the code without a console? – CristiFati Feb 21 '19 at 07:07
  • @CristiFati, my school has python installed on all the computers, and pywin32 is not installed (I already tried importing it). – object-Object Feb 21 '19 at 18:18
  • OK, you didn't answer to my question. Besides, this task seems more than overwhelming for a student. Nevertheless, you have all the needed material to go on. – CristiFati Feb 22 '19 at 00:30
  • I have no idea what the additional prossesing would be. – object-Object Feb 26 '19 at 15:57

0 Answers0