I am automating the installation of software using python with pyautogui:
import pyautogui
import time
import pyperclip
for window in pyautogui.getWindows():
pyautogui.getWindow(window).minimize()
##Abre local do .exe
pyautogui.hotkey("win","r")
pyautogui.press("\")
pyautogui.press("\")
pyperclip.copy("ts1/publico/Meus Documentos/Equipes Qualidade/Automação/Aplicativos/Folha/Sefip 8.4")
pyautogui.hotkey("ctrl","v")
pyautogui.press("enter")
##Encontra .exe e da double click nele
executavel = None
while executavel is None:
executavel = pyautogui.locateOnScreen("executavel.png", grayscale=False)
executalvelX, executavelY = pyautogui.center(executavel)
pyautogui.click(executalvelX, executavelY, clicks=2)
##O instalador abre, aqui ele deveria encontrar o botão 'sim' e clicar nele.
##O Script encontra a posição do botao, porém não clica, não pressiona teclas, não move o mouse.
botaoSim = None
while botaoSim is None:
botaoSim = pyautogui.locateOnScreen("botaosim.png", grayscale=False)
botaoSimX, botaoSimY = pyautogui.center(botaoSim)
pyautogui.click(botaoSimX, botaoSimY)
for _ in range(4):
next1 = None
while next1 is None:
next1 = pyautogui.locateOnScreen("next.png", grayscale=False)
next1X, next1Y = pyautogui.center(next1)
pyautogui.click(next1X, next1Y)
However, at some stage in the process, some functions such as clicking, moving the mouse, pressing a key do not work.
I would like to know if I am doing something wrong, or if it is because it is an installation of a system.