T
T
Tayrus02020-03-03 20:13:00
Python
Tayrus0, 2020-03-03 20:13:00

Why am I getting the pywinauto.application.AppNotConnected error?

The code:

import pywinauto
from pywinauto import win32functions,win32defines
import time
import win32clipboard
import win32gui
import win32com.client
import subprocess
time.sleep(2)

ms=win32functions.SendMessage
shell = win32com.client.Dispatch("WScript.Shell")
pwa_app = pywinauto.application.Application()

try:
    w = pywinauto.findwindows.find_windows(class_name='CabinetWClass')[0]
except: 
    w = pywinauto.findwindows.find_windows(class_name='Progman')[0]

window = pwa_app.window(handle=w)


Mistake:
C:\Users\ALEX\Desktop>python teee.py
Traceback (most recent call last):
  File "teee.py", line 19, in <module>
    window = pwa_app.window(handle=w)
  File "C:\Users\ALEX\AppData\Local\Programs\Python\Python37\lib\site-packages\pywinauto\application.py", line 1226, in window
    raise AppNotConnected("Please use start or connect before trying "
pywinauto.application.AppNotConnected: Please use start or connect before trying anything else

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alekssamos, 2020-03-03
@alekssamos

After the imports, do Application.StarteitherApplication.Connect

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question