'Pyautogui stops working after using "os.startfile"
I'm creating a bot for installing a bunch of programs automatically but when I run it the pyautogui seems to not working.
Here I leave the code:
import pyautogui
import os
import time
def arturia3filters():
os.startfile("MYDIRECTORY/Setup.exe")
print('Opening Arturia 3 Filters')
time.sleep(15)
print('Trying to click icon')
pyautogui.moveTo(1000, 560)
pyautogui.click(x=1000, y=560)
print('Clicked')
time.sleep(4)
pyautogui.hotkey('alt', 'n')
print('HT N')
time.sleep(1)
pyautogui.hotkey('alt', 'r')
print('HT R')
arturia3filters()
Also when I try to run the program without the "os.startfile", it works good, very strange.
Solution 1:[1]
This works with the full path of the file. I create a test txt file in my c drive (on windows10) as per below and this is fine.
see code below.
import pyautogui
import os
import time
def arturia3filters():
os.startfile(r"C:\darren\test.txt")
print('Opening Arturia 3 Filters')
time.sleep(15)
print('Trying to click icon')
pyautogui.moveTo(1000, 560)
pyautogui.click(x=1000, y=560)
print('Clicked')
time.sleep(4)
pyautogui.hotkey('alt', 'n')
print('HT N')
time.sleep(1)
pyautogui.hotkey('alt', 'r')
print('HT R')
arturia3filters()
In my case, it opens the notepad text editor with the file that is pointed to in the os.startfile() command.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | D.L |
