谁能帮我用python代码来捕获附件图像:
Try this Code -
import time
from pywinauto.application import Application
from PIL import ImageGrab
# connect to task bar
app = Application().Connect(title=u'', class_name='Shell_TrayWnd')
# Get task bar window
shelltraywnd = app.Shell_TrayWnd
# Get tray clock window
trayclockwclass = shelltraywnd.TrayClockWClass
# Get rectangle of tray clock window
clockRect = trayclockwclass.client_rect()
# Click into the rectangle of tray clock window
trayclockwclass.click_input(coords=(clockRect.left+20, clockRect.bottom-20))
# wait for Clock Flyout to appear
time.sleep(5)
# Grab the top screen
screenBuffer = ImageGrab.grab()
# Save Path/filename
save_path = "yourScreen.jpg"
# Save into file
screenBuffer.save(save_path)
pip install pywinauto
pip install Pillow
from pywinauto import Desktop, Application app = Application().start(r'C:\WINDOWS\system32\notepad.exe') win = app['UntitledNotepad'] win.type_keys('hello world') win.capture_as_image().save('screenshot.png')
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.