I am trying to automate saving each tab in my open browser (Google Chrome). This code used to work before when it operated from the command prompt, but now I am making a GUI to use the functions and I get this error.
here is the function that uses Application.connect().
# saves all current tabs to clipboard and closes browser
def save_and_close(self):
global URLS
# list that contains new URLS for storage
updated_data = []
# account for any internet-related disconnections
try:
app = Application(backend='uia').connect(path = self.browser_location)
find_windows(title = "Google Chrome")
while True:
try:
keyboard.send_keys("{F6}^c")
time.sleep(1)
updated_data.append(clipboard.GetData())
time.sleep(3)
keyboard.send_keys("^w")
time.sleep(3)
except KeyboardInterrupt:
keyboard.send_keys("^") # undo the keyboard control key
break
# updates database with new URLS
with open("bmanager.json", "w") as dw:
json.dump(updated_data, dw)
# reloads database for next possible usage
URLS = json.loads(open("bmanager.json").read())
except Exception as e:
print(e)
print ("[ERROR]: Client is not connected to the internet")
Here is the error:
Process [browser location] not found!
Note that [browser location] is just a placeholder for the location of my browser's .exe file
I figured out that I have to register chrome using the location and pywinauto's register function before connecting to it.