How do I have to code it like I want to make new png file? When I press "P" save the png file name as "A(number)".
import time
import pyautogui as pag
import keyboard
A = 0
while True: # making a loop
try: # used try so that if user pressed other than the given key error will not be shown
if keyboard.read_key() == "p": # if key 'q' is pressed
myScreenshot = pag.screenshot()
myScreenshot.save(r'C:\Users\Users\Desktop\"A".png') #name as "A".png
time.sleep(1)
A = A+1
break # finishing the loop
except:
break # if user pressed a key other than the given key the loop will break