1
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 certain stage of the process, some functions like clicking, moving the mouse, pressing a key do not work.
I wonder if I’m doing something wrong, or if it’s because it’s a system installation.
The script still running? Error appears?
– Woss
@Andersoncarloswoss The script is still running, no errors, it finds the position of the "yes" and goes on, goes through the for (which is clicking next - also happens the same thing, finds the positions but goes straight through the click)
– Nathan Schroeder
The program will not have lost its focus?
– lazyFox
I have tested this possibility, but have not succeeded, except if I have done wrong...
– Nathan Schroeder