初めに
私は理系大学2年生です。大学に入って初めてプログラミングに触れたため経験歴はとても低いです。そんな中、目標を立てて作ってみたソフトを公開してみました。
作ったもの
タイトルにも書いてある通り、ディスプレイごとにスクリーンショットが取れるソフトを作りました。
デュアルディスプレイ、マルチディスプレイ環境にてスクショを撮ると、画像がつながった状態になっています。そこで、ディスプレイ一つ一つでスクショが撮れるソフトを作りました。
使用言語 python 3.7
確認が取れている動作環境 Windows10(64bit), windows11
pcのスペックが低いと動作が重い可能性があります。
exe化に使用したもの Nuitka
ソースコード
長いですが、お許しください。ご自由に使っていただいて結構です。
from tkinter import *
from tkinter import filedialog
import tkinter as tk
from pynput import keyboard #LGPLv3
from PIL import ImageGrab, Image #HPND
import getpass
import os
import datetime
import time
from concurrent.futures import ThreadPoolExecutor
from screeninfo import get_monitors #MIT
import cv2 #MIT
from pystray import Icon, Menu, MenuItem #LGPLv3
from win32 import win32gui #PSF
import gc
import sys
f = open(os.devnull, 'w')
sys.stderr = f
sys.stdout = f
sys.stdin = f
#Global variable definition
user = getpass.getuser()
dir_path = 'C:\\Users\\{}\\Pictures'.format(user)
filename = ''
dis_count = 0 #ディスプレイの枚数
temp_windowx_cd = [0] #仮のディスプレイの左上の座標 X
temp_windowy_cd = [0] #仮のディスプレイの左上の座標 Y
windowx_cd = [0] #最終的に使う数
windowy_cd = [0] #最終的に使う数
windowx_size = [0] #ディスプレイの解像度(サイズ)
windowy_size = [0] #ディスプレイの解像度(サイズ)
min_x_cd = 10000000 #初期設定 数は適当
min_y_cd = 10000000 #初期設定 数は適当
for d in get_monitors():
dis_count = dis_count + 1
#Add display information to the array
Range = range(0, dis_count)
for data in Range:
monitor = get_monitors()[data]
temp_windowx_cd[data] = monitor.x
temp_windowy_cd[data] = monitor.y
windowx_size[data] = monitor.width
windowy_size[data] = monitor.height
for i in Range: #座標比較
if temp_windowx_cd[i] < min_x_cd:
min_x_cd = temp_windowx_cd[i]
if temp_windowy_cd[i] < min_y_cd:
min_y_cd = temp_windowy_cd[i]
for j in Range: #切り抜きに使う数値へ変更
windowx_cd[j] = -1 * min_x_cd + temp_windowx_cd[j]
windowy_cd[j] = -1 * min_y_cd + temp_windowy_cd[j]
icon_data = """
R0lGODlhQAFAAfZ7AAAAACElliMnmCMomCcrmScrmiwwmy4wnS0ynDAznTE0njM0
njE2njY6oDc7oDs+ozs/pD1Aoz9BpEBDpEFEpUZKqUhMqUpMqUxQqk1QqlNVrVNW
rlVXrlVXr1lbr1ZYsFZZsFpdslxfsVxfs11hs2JmtWZouGZpuGhruGptuWxtumxv
um1uu3B0vXJ1vHd8wHp9wHp9wX6AwX+Bw3+Cw4CDwoGExIKExIOExYeJx4qMx4mM
yImMyYqMyJCTy5eZzpiazpud0J+g0aCh0qGj06Kj06Kk1KOl1amq1qqs1qqs16us
16qs2K6v2a+w2rO127i53rq63sTG48TG5MvM583P6M7O6M/P6NLT6tXV69TW69bX
69fX7NXY69jZ7NjZ7dna7dra7tvb7tzc79/g7+Dg7+Dg8OHh8erq9err9e/v9+/v
+PHx+PLy+fLz+fPz+fT0+fT0+vT1+vb2+vb2+/f3+/j4+/j4/Pv7/fv8/fz8/v//
/wAAAAAAAAAAAAAAACH5BAEAAAAAIf8LWE1QIERhdGFYTVA8P3hwYWNrZXQgYmVn
aW49J++7vycgaWQ9J1c1TTBNcENlaGlIenJlU3pOVGN6a2M5ZCc/Pgo8eDp4bXBt
ZXRhIHhtbG5zOng9J2Fkb2JlOm5zOm1ldGEvJyB4OnhtcHRrPSdJbWFnZTo6RXhp
ZlRvb2wgMTIuNDAnPgo8cmRmOlJERiB4bWxuczpyZGY9J2h0dHA6Ly93d3cudzMu
b3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMnPgoKIDxyZGY6RGVzY3JpcHRp
b24gcmRmOmFib3V0PScnCiAgeG1sbnM6dGlmZj0naHR0cDovL25zLmFkb2JlLmNv
bS90aWZmLzEuMC8nPgogIDx0aWZmOk9yaWVudGF0aW9uPjE8L3RpZmY6T3JpZW50
YXRpb24+CiA8L3JkZjpEZXNjcmlwdGlvbj4KPC9yZGY6UkRGPgo8L3g6eG1wbWV0
YT4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAK
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
IAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAKPD94cGFja2V0IGVuZD0ndyc/PgH/
/v38+/r5+Pf29fTz8vHw7+7t7Ovq6ejn5uXk4+Lh4N/e3dzb2tnY19bV1NPS0dDP
zs3My8rJyMfGxcTDwsHAv769vLu6ubi3trW0s7KxsK+urayrqqmop6alpKOioaCf
np2cm5qZmJeWlZSTkpGQj46NjIuKiYiHhoWEg4KBgH9+fXx7enl4d3Z1dHNycXBv
bm1sa2ppaGdmZWRjYmFgX15dXFtaWVhXVlVUU1JRUE9OTUxLSklIR0ZFRENCQUA/
Pj08Ozo5ODc2NTQzMjEwLy4tLCsqKSgnJiUkIyIhIB8eHRwbGhkYFxYVFBMSERAP
Dg0MCwoJCAcGBQQDAgEAACwAAAAAQAFAAQAH/oAAgoOEhYaHiImKi4yNjo+QkZKT
lJWWl5iZmpucnZ6foKGio6SlpqeoqaqrrK2ur7Cxspprtba3uGuDHry9vr+/BcLD
xMXELCrJKiwsK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J+PnMzELOjnOS3DSaM2mS
JDn2Etbbto1OtzfjhhAxVw6MrXTq1L2KxfHWGDDyFIocmTCfyWP7ljlb1AgOQGmM
XsIJOIekTWAMTTmUFI5IEIqrLKbL1YXWxVtGcYG8ybSpr5MnUxrqhwhAnpgu5zCy
Q9BNQadgw4odS7as2bNo06pdy7at27dw48qdS7eu3bt48+rdy7ev37+AAwseTLiw
4cOIEytezLixY2GBAAA7"""
def all():
import keyboard #MIT
keyboard.release('left ctrl')
keyboard.release('right ctrl')
keyboard.release('1')
keyboard.release('2')
keyboard.release('3')
keyboard.release('4')
keyboard.release('5')
keyboard.release('6')
keyboard.release('7')
keyboard.release('8')
keyboard.release('9')
keyboard.release('a')
keyboard.release('b')
keyboard.release('c')
keyboard.release('d')
keyboard.release('e')
keyboard.release('f')
keyboard.release('left shift')
keyboard.release('right shift')
#タスクトレイにてアイコン表示
def ICON():
def quit_app():
icon.stop()
closed()
#アクティブ化
def run_app():
akuthibu = win32gui.FindWindow(None, 'DisShot')
time.sleep(1)
win32gui.SetForegroundWindow(akuthibu)
image = Image.open('E.ico')
menu = Menu(MenuItem('表示', run_app), MenuItem('終了', quit_app))
icon = Icon(name='test', icon=image, title='DisShot', menu=menu)
icon.run()
#create GUI
def make_display():
global dir_path
def get_photo_image4icon():
return tk.PhotoImage(data=icon_data) # PhotoImageオブジェクトの作成
#print("moving data")
root = tk.Tk()
root.title('DisShot')
root.geometry('250x150')
root.attributes("-toolwindow",1)
root.protocol("WM_DELETE_WINDOW",closed)
root.resizable(0,0)
photo = get_photo_image4icon()
root.iconphoto(False, photo)
#object definition
def dirdialog_clicked():
global dir_path
current_dir = os.path.abspath(os.path.dirname(__file__))
dir_path = filedialog.askdirectory(initialdir=current_dir)
entry_ws.set(dir_path)
def display_research():
global dis_count, temp_windowx_cd, temp_windowy_cd,windowx_cd, windowy_cd, windowx_size, windowy_size, min_x_cd, min_y_cd
#以下、再定義
dis_count = 0 #ディスプレイの枚数
temp_windowx_cd = [0] #仮のディスプレイの左上の座標 X
temp_windowy_cd = [0] #仮のディスプレイの左上の座標 Y
windowx_cd = [0] #最終的に使う数
windowy_cd = [0] #最終的に使う数
windowx_size = [0] #ディスプレイの解像度(サイズ)
windowy_size = [0] #ディスプレイの解像度(サイズ)
min_x_cd = 10000000 #初期設定 数は適当
min_y_cd = 10000000 #初期設定 数は適当
#numbur of display
for d in get_monitors():
dis_count = dis_count + 1
#Add display information to the array
Range = range(0, dis_count)
for data in Range:
monitor = get_monitors()[data]
temp_windowx_cd[data] = monitor.x
temp_windowy_cd[data] = monitor.y
windowx_size[data] = monitor.width
windowy_size[data] = monitor.height
for i in Range: #座標比較
if temp_windowx_cd[i] < min_x_cd:
min_x_cd = temp_windowx_cd[i]
if temp_windowy_cd[i] < min_y_cd:
min_y_cd = temp_windowy_cd[i]
for j in Range: #切り抜きに使う数値へ変更
windowx_cd[j] = -1 * min_x_cd + temp_windowx_cd[j]
windowy_cd[j] = -1 * min_y_cd + temp_windowy_cd[j]
lebel_1 = tk.Label(root, text='画像保存先を指定')
entry_ws = tk.StringVar()
dir_entry = tk.Entry(root, textvariable=entry_ws, width=20)
dir_button = tk.Button(root, text="参照", command=dirdialog_clicked)
research_button = tk.Button(root, text="ディスプレイ再カウント", command=display_research)
lebel_1.pack()
#↓ これによって初めからエントリーダイアログに入力されている形
dir_entry.insert(tk.END, dir_path)
dir_entry.pack()
dir_button.pack()
research_button.pack()
root.mainloop()
#program termination constant
def closed():
os.kill(os.getpid(), 9)
#save screenshot and name it
def save_image():
global dir_path, filename
screenshot = ImageGrab.grab(all_screens=True)
#ファイルネーム指定
now = datetime.datetime.now()
filename = 'disShot' + now.strftime('%Y%m%d_%H%M%S') + '.png'
screenshot.save(dir_path +'\\'+ filename, quaality = 100)
#take screenshot and save photo
def screen_shot_1():
global user, dir_path, dis_count, filename, windowx_cd, windowy_cd, windowx_size, windowy_size
if dis_count >= 1:
save_image()
img = cv2.imread('{}\\{}'.format(dir_path, filename))
img1 = img[windowy_cd[0] : windowy_size[0] + windowy_cd[0], windowx_cd[0] : windowx_size[0] + windowx_cd[0]]
cv2.imwrite('{}\\{}'.format(dir_path, filename), img1)
#gc.collect()
all()
gc.collect()
time.sleep(0.05)
def screen_shot_2():
global user, dir_path, dis_count, filename, windowx_cd, windowy_cd, windowx_size, windowy_size
if dis_count >= 2:
save_image()
img = cv2.imread('{}\\{}'.format(dir_path, filename))
img1 = img[windowy_cd[1] : windowy_size[1] + windowy_cd[1], windowx_cd[1] : windowx_size[1] + windowx_cd[1]]
cv2.imwrite('{}\\{}'.format(dir_path, filename), img1)
all()
gc.collect()
time.sleep(0.05)
def screen_shot_3():
global user, dir_path, dis_count, filename, windowx_cd, windowy_cd, windowx_size, windowy_size
if dis_count >= 3:
save_image()
img = cv2.imread('{}\\{}'.format(dir_path, filename))
img1 = img[windowy_cd[2] : windowy_size[2] + windowy_cd[2], windowx_cd[2] : windowx_size[2] + windowx_cd[2]]
cv2.imwrite('{}\\{}'.format(dir_path, filename), img1)
all()
gc.collect()
time.sleep(0.05)
def screen_shot_4():
global user, dir_path, dis_count, filename, windowx_cd, windowy_cd, windowx_size, windowy_size
if dis_count >= 4:
save_image()
img = cv2.imread('{}\\{}'.format(dir_path, filename))
img1 = img[windowy_cd[3] : windowy_size[3] + windowy_cd[3], windowx_cd[3] : windowx_size[3] + windowx_cd[3]]
cv2.imwrite('{}\\{}'.format(dir_path, filename), img1)
all()
gc.collect()
time.sleep(0.05)
def screen_shot_5():
global user, dir_path, dis_count, filename, windowx_cd, windowy_cd, windowx_size, windowy_size
if dis_count >= 5:
save_image()
img = cv2.imread('{}\\{}'.format(dir_path, filename))
img1 = img[windowy_cd[4] : windowy_size[4] + windowy_cd[4], windowx_cd[4] : windowx_size[4] + windowx_cd[4]]
cv2.imwrite('{}\\{}'.format(dir_path, filename), img1)
all()
gc.collect()
time.sleep(0.05)
def screen_shot_6():
global user, dir_path, dis_count, filename, windowx_cd, windowy_cd, windowx_size, windowy_size
if dis_count >= 6:
save_image()
img = cv2.imread('{}\\{}'.format(dir_path, filename))
img1 = img[windowy_cd[5] : windowy_size[5] + windowy_cd[5], windowx_cd[5] : windowx_size[5] + windowx_cd[5]]
cv2.imwrite('{}\\{}'.format(dir_path, filename), img1)
all()
gc.collect()
time.sleep(0.05)
def screen_shot_7():
global user, dir_path, dis_count, filename, windowx_cd, windowy_cd, windowx_size, windowy_size
if dis_count >= 7:
save_image()
img = cv2.imread('{}\\{}'.format(dir_path, filename))
img1 = img[windowy_cd[6] : windowy_size[6] + windowy_cd[6], windowx_cd[6] : windowx_size[6] + windowx_cd[6]]
cv2.imwrite('{}\\{}'.format(dir_path, filename), img1)
all()
gc.collect()
time.sleep(0.05)
def screen_shot_8():
global user, dir_path, dis_count, filename, windowx_cd, windowy_cd, windowx_size, windowy_size
if dis_count >= 8:
save_image()
img = cv2.imread('{}\\{}'.format(dir_path, filename))
img1 = img[windowy_cd[7] : windowy_size[7] + windowy_cd[7], windowx_cd[7] : windowx_size[7] + windowx_cd[7]]
cv2.imwrite('{}\\{}'.format(dir_path, filename), img1)
all()
gc.collect()
time.sleep(0.05)
def screen_shot_9():
global user, dir_path, dis_count, filename, windowx_cd, windowy_cd, windowx_size, windowy_size
if dis_count >= 9:
save_image()
img = cv2.imread('{}\\{}'.format(dir_path, filename))
img1 = img[windowy_cd[8] : windowy_size[8] + windowy_cd[8], windowx_cd[8] : windowx_size[8] + windowx_cd[8]]
cv2.imwrite('{}\\{}'.format(dir_path, filename), img1)
all()
gc.collect()
time.sleep(0.05)
def screen_shot_a():
global user, dir_path, dis_count, filename, windowx_cd, windowy_cd, windowx_size, windowy_size
if dis_count >= 10:
save_image()
img = cv2.imread('{}\\{}'.format(dir_path, filename))
img1 = img[windowy_cd[9] : windowy_size[9] + windowy_cd[9], windowx_cd[9] : windowx_size[9] + windowx_cd[9]]
cv2.imwrite('{}\\{}'.format(dir_path, filename), img1)
all()
gc.collect()
time.sleep(0.05)
def screen_shot_b():
global user, dir_path, dis_count, filename, windowx_cd, windowy_cd, windowx_size, windowy_size
if dis_count >= 11:
save_image()
img = cv2.imread('{}\\{}'.format(dir_path, filename))
img1 = img[windowy_cd[10] : windowy_size[10] + windowy_cd[10], windowx_cd[10] : windowx_size[10] + windowx_cd[10]]
cv2.imwrite('{}\\{}'.format(dir_path, filename), img1)
all()
gc.collect()
time.sleep(0.05)
def screen_shot_c():
global user, dir_path, dis_count, filename, windowx_cd, windowy_cd, windowx_size, windowy_size
if dis_count >= 12:
save_image()
img = cv2.imread('{}\\{}'.format(dir_path, filename))
img1 = img[windowy_cd[11] : windowy_size[11] + windowy_cd[11], windowx_cd[11] : windowx_size[11] + windowx_cd[11]]
cv2.imwrite('{}\\{}'.format(dir_path, filename), img1)
all()
gc.collect()
time.sleep(0.05)
def screen_shot_d():
global user, dir_path, dis_count, filename, windowx_cd, windowy_cd, windowx_size, windowy_size
if dis_count >= 13:
save_image()
img = cv2.imread('{}\\{}'.format(dir_path, filename))
img1 = img[windowy_cd[12] : windowy_size[12] + windowy_cd[12], windowx_cd[12] : windowx_size[12] + windowx_cd[12]]
cv2.imwrite('{}\\{}'.format(dir_path, filename), img1)
all()
gc.collect()
time.sleep(0.05)
def screen_shot_e():
global user, dir_path, dis_count, filename, windowx_cd, windowy_cd, windowx_size, windowy_size
if dis_count >= 14:
save_image()
img = cv2.imread('{}\\{}'.format(dir_path, filename))
img1 = img[windowy_cd[13] : windowy_size[13] + windowy_cd[13], windowx_cd[13] : windowx_size[13] + windowx_cd[13]]
cv2.imwrite('{}\\{}'.format(dir_path, filename), img1)
all()
gc.collect()
time.sleep(0.05)
def screen_shot_f():
global user, dir_path, dis_count, filename, windowx_cd, windowy_cd, windowx_size, windowy_size
if dis_count >= 15:
save_image()
img = cv2.imread('{}\\{}'.format(dir_path, filename))
img1 = img[windowy_cd[14] : windowy_size[14] + windowy_cd[14], windowx_cd[14] : windowx_size[14] + windowx_cd[14]]
cv2.imwrite('{}\\{}'.format(dir_path, filename), img1)
all()
gc.collect()
time.sleep(0.05)
#ended
'''
def Print():
global windowx_cd, windowy_cd, windowx_size, windowy_size, dis_count
while True:
print(windowx_cd)
print(windowy_cd)
print(windowx_size)
print(windowy_size)
print('count : ', dis_count)
time.sleep(3)
'''
def keyboardShotcut():
with keyboard.GlobalHotKeys({
'<ctrl>+<shift>+1': screen_shot_1,
'<ctrl>+<shift>+2': screen_shot_2,
'<ctrl>+<shift>+3': screen_shot_3,
'<ctrl>+<shift>+4': screen_shot_4,
'<ctrl>+<shift>+5': screen_shot_5,
'<ctrl>+<shift>+6': screen_shot_6,
'<ctrl>+<shift>+7': screen_shot_7,
'<ctrl>+<shift>+8': screen_shot_8,
'<ctrl>+<shift>+9': screen_shot_9,
'<ctrl>+<shift>+a': screen_shot_a,
'<ctrl>+<shift>+b': screen_shot_b,
'<ctrl>+<shift>+c': screen_shot_c,
'<ctrl>+<shift>+d': screen_shot_d,
'<ctrl>+<shift>+e': screen_shot_e,
'<ctrl>+<shift>+f': screen_shot_f}) as h:
h.join()
if __name__ == "__main__":
with ThreadPoolExecutor(max_workers=3) as executor:
executor.submit(keyboardShotcut)
executor.submit(make_display)
executor.submit(ICON)
#executor.submit(Print)
使い方
ダウンロード先
ダウンロードは以下からできます。
https://github.com/juannu1028/DisShot/tree/test
DisShot.zipをインストールしてください。
起動したら
以下のようなものが表示されます。
参照ボタンまたは入力欄に保存先を選択、入力してください。
デフォルトはc:\User\ユーザー名\Pictures
(場合によってはこのpathでは使えません)
ソフトを立ち上げた状態でディスプレイの配置を変えた、新しく接続した場合はディスプレイ再カウントを押してください。
また、タスクトレイにアイコンが出ます(ハサミのマーク)。右クリックで表示と終了が出ます。
これでウィンドウをアクティブ化したり、タスクトレイからも終了したりできます。
コマンド(ショートカットキー)
スクショはすべてショートカットキーで行います。
ディスプレイ番号はwindoswの設定から各自確認してください。
ディスプレイの番号は16進数でカウントしてください
ディスプレイの最大認識数は15枚となっています。
キーは以下の通りです。
ctrl + shift + ディスプレイ番号
つまり、5枚目のディスプレイを撮りたいのであれば、
ctrl + shift + 5
また、14枚目のでぃすれぷいを撮りたいのであれば、
ctrl + shift + e
という形になっています。
大量のディスプレイを準備できないので私の環境では4枚まで動作していることを確認しています。
改善したい点
①一部ショートカットキーがかぶってしまっていたため、別のパターンを考えたい。
②起動が遅い。exe化にNuitkaを使ったのが原因?
③画像保存pathに日本語が混ざっているとエラーが起きているので直したい。
④画像保存pathを参照ボタンを押して選択中にキャンセルボタン、excapeボタンを押すとpathが空白になってしまう問題を直したい。
⑤classを使えるようにしたい。ソースコードで似たような処理をしているところがあるので、もっと見やすく少ないコードにできるようにしたい。
最後に
読んでくださり有難うございました。このソフトはwindowsでしか使えないので今度はlinuxでも使えるようにしたいと考えています。macOSは触ったことも見たこともないので知りませんが()。
また、今回簡単なソフトウェアとはいえ作ってみると、失敗ばっかり続いていたので改善点が多いですが、ここまで来れてわからないことがまだ多すぎると感じています。しかし、楽しさや満足感が気持ちいいのでしばらくソフトウェア勉強は続けられそうです。ハードウェアの知識も欲しいですね....