简体   繁体   中英

how to combine these two python scripts?

how to combine these two python scripts. I am trying to use it in eventghost to capture screenshot of active windows with title name

i can use the screenshots to restore a pc session incase windows crash

sorry, if i formatted my question in bad format. i came back here after a long time and tried my best to put my query in best way

import ImageGrab, datetime
im = ImageGrab.grab()
date = datetime.datetime.now()
str = date.strftime("%Y%m%d%H%M%S")
im.save(r'D:\temp\DELETE NOW\screenshot%s.png' % str)

---------------------------

import win32gui
w=win32gui
w.GetWindowText (w.GetForegroundWindow())

Not sure what order you want to run them in, but:

import ImageGrab, datetime
import win32gui

w=win32gui
w.GetWindowText (w.GetForegroundWindow())

im = ImageGrab.grab()
date = datetime.datetime.now()
str = date.strftime("%Y%m%d%H%M%S")
im.save(r'D:\temp\DELETE NOW\screenshot%s.png' % str)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM