Can anyone please help me with python code to capture the attached image:
Asked
Active
Viewed 1,712 times
0
-
Kindly note that clicking on the link will pop the image. – techlearner Jun 07 '22 at 10:38
-
Please provide enough code so others can better understand or reproduce the problem. – Community Jun 07 '22 at 20:02
2 Answers
1
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')

Zhiwei
- 66
- 4
0
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)

Sachin
- 151
- 7
-
Thanks Sachin Patole for the reply. I am experiencing the below error while running the line - "from pywinauto.application import Application" : 'ImportError: DLL load failed while importing win32ui: A dynamic link library (DLL) initialization routine failed.' – techlearner Jul 03 '22 at 04:41
-
Refer to this - https://stackoverflow.com/questions/64655079/cannot-import-from-pywinauto-importerror-dll-load-failed-while-importing-win32 – Sachin Jul 05 '22 at 07:10