I am facing an issue while taking screen shots using mss module in python, sometimes it is working fine and some times giving black screen as output. Please provide me solution for this problem.
I have tried to take screen shots with mostly all the available modules in python, Some times they are working and some times they are not working. -->Some times it will work through command prompt. If same i tried with pyqt5 not working.
from mss import mss
import win32com.client
if __name__ == '__main__':
while 1:
print("Extension is required for file name... 1.YES 2.NO")
filenamerequirement=input(">")
if(filenamerequirement=='1'):
print("Enter the Extension")
Extension=input(">")
xlApp = win32com.client.Dispatch("Excel.Application")
RequirementID=xlApp.ActiveCell
RequirementID=int(RequirementID)
if(filenamerequirement == '1'):
picname=str(RequirementID)+Extension+'.png'
picname=str(picname)
elif(filenamerequirement == '2'):
picname=str(RequirementID)+'.png'
picname=str(picname)
with mss() as sct:
filename = sct.shot(mon=2, output=picname)
#filename = sct.shot(mon=2, output='111.png')
Expected Result: Screen shot with actual content Actual Result: Black screen