使用python调用系统截图工具 snip&sketch
作者:互联网
参考自Snip-Sketch-OCR/cpocr.py at master · vishvaluke/Snip-Sketch-OCR (github.com)
删除了ocr部分。剩余功能:调用系统截图工具并且保存在本地
from multiprocessing import Process
from pyperclip import copy
def mino():
import ctypes
ctypes.windll.user32.ShowWindow(ctypes.windll.kernel32.GetConsoleWindow(), 6)
copy('')
def starto():
from os import system
system('explorer ms-screenclip:')
def runo():
from PIL import ImageGrab as ig
img = ig.grabclipboard()
i = 0
from time import sleep
while (img == None):
i += 1
sleep(1)
img = ig.grabclipboard()
if i > 9:
exit()
img = ig.grabclipboard()
img = img.convert('RGB')
img.save('paste.png', 'PNG')
def screenshot():
print('start screenshot')
p1 = Process(target=starto)
p1.start()
p2 = Process(target=mino)
p2.start()
p1.join()
p2.join()
runo()
if __name__ == '__main__':
screenshot()
标签:__,sketch,img,python,snip,start,def,import,ig 来源: https://blog.csdn.net/m0_59859442/article/details/119275724