import os
import datetime
import time
import numpy as np
from IPython.display import Image, display
def get_screenshot():
fp = r"C:\Users\Sean Fuller\AppData\Local\Packages\MicrosoftWindows.Client.CBS_cw5n1h2txyewy\TempState\ScreenClip"
fn_list = []
mtime_list = []
sz_list = []
for fn in os.listdir(fp):
if fn.endswith('.png'):
fn_list.append(fn)
mtime_list.append(datetime.datetime.strptime(time.ctime(os.path.getmtime(fr'{fp}\{fn}')), "%a %b %d %H:%M:%S %Y"))
sz_list.append(os.path.getsize(fr'{fp}\{fn}'))
max_idx = np.argmax([sz for mtime, sz in sorted(zip(mtime_list, sz_list), key=lambda pair: pair[0], reverse=True)][:2])
screenshot = [fn for mtime, fn in sorted(zip(mtime_list, fn_list), key=lambda pair: pair[0], reverse=True)][max_idx]
import shutil
fpdest = r'C:\Users\Sean Fuller\Desktop\MSDS\422\MLE_Notes\img'
cfile = fr'{fp}\{screenshot}'
shutil.copy2(cfile, fpdest)
print(rf'')
print('***')
print('')
display(Image(filename = fr'{fp}\{screenshot}'))
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter