[英]How to take screenshot using pywinauto in python
谁能帮我用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点安装 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')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.