Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
484 views
in Technique[技术] by (71.8m points)

pyautogui - How to take screenshot in python when pc is in standby mode

I'm automatically launching some python scripts that take screenshots and analysing screen content using pyautogui module. When my pc is in standby mode, the script run but take a screenshot of the standby mode. Are there any solution to take a screenshot of the window content even if the pc is on standby mode.

I appreciate your help. Thank you.

question from:https://stackoverflow.com/questions/65934505/how-to-take-screenshot-in-python-when-pc-is-in-standby-mode

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I don't think such thing is possible in sleep mode, meanwhile you can prevent your computer from going into standby mode by referring to this :

The main idea is using SetThreadExecutionState function, for example, in your python terminal you can run :

import ctypes
ctypes.windll.kernel32.SetThreadExecutionState(0x80000002)
input('{Press enter to exit}')
ctypes.windll.kernel32.SetThreadExecutionState(0x80000000)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...