How to save an image obtained with: pyautogui.hotkey('Alt','printscreen')?

Asked

Viewed 65 times

0

I need to save image obtained by pyautogui.hotkey('Alt','printscreen')

In the example below I used pyautogui.screenshot(), but I wanted to catch one print of active window only.

time.sleep(2);
foto = pyautogui.screenshot();
nomeArquivo = win32gui.GetWindowText(win32gui.GetForegroundWindow()) + '.jpg';
nomeArquivo = nomeArquivo.replace('Código: ','');
nomeArquivo = nomeArquivo.replace(' - Imagem Ampliada','');
foto.save('C://Tmp//' + nomeArquivo);

1 answer

0


I solved partially using

pyautogui.screenshot(region=(418,193, 531, 469));

#captured the dimension of the window

regiao=win32gui.GetWindowRect(win32gui.GetForegroundWindow());

#I tried to print the area

foto = pyautogui.screenshot(region=(regiao[0]+5,regiao[1]+20,regiao[2]-regiao[0]-10,regiao[3]-(regiao[1]+23)));

Browser other questions tagged

You are not signed in. Login or sign up in order to post.