I'm trying to run one script from another script. I've read; What is the best way to call a script from another script? and I can't seem to get this to work.
My main script (Script A) does a lot of image processing and GUI interactions. However, randomly an error message or other window might appear interrupting the GUI interactions until the message or window is closed.
I've written a second script (Script B) that I want to run perpetually that closes these windows or error messages when discovered.
I'm trying to call Script B from Script A like this:
import close_windows
close_windows.closeWindows
print("Starting Close Windows....")
And Script B is:
import pyautogui as py
def closeWindows():
image = r'C:\image.jpg'
image2 = r'C:\image2.jpg'
while True:
foundimage = py.locateCenterOnScreen(image)
foundimage2 = py.locateCenterOnScreen(image2)
if foundimage or foundimage2 != None:
py.click(1887, 65)
When I run script B independently it works, when I try running it via Script A with close_windows.closeWindows
nothing happens.
I've also tried from close_windows import closeWindows
and calling closeWindows
but again, nothing happens.