You can take a screen capture of the screen by pressing Ctrl + (Alt | Shift) + PrintScreen, but if you press Ctrl, the screen capture will be saved on the clipboard. (Usually you can press (Alt | Shift) + PrintScreen without pressing Ctrl to bring up a dialog and save it to a file.)
This time, save the image saved on the clipboard to a file with Python. By the way, it cannot be executed without GTK environment.
clip2img.py
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import gtk
def save_clipimg(filename):
clipboard = gtk.clipboard_get()
image = clipboard.wait_for_image()
if image is not None:
image.save(filename, "png")
else:
print("No image in clipborad.")
def main():
save_clipimg((sys.argv+["clipboard.png "])[1])
main()
Originally, I should use paint software quietly.
Recommended Posts