Hello I'm trying to automate a file drop process and here's my Python script, with AutoIT imported via the win32com module
from selenium import webdriver
import win32com.client
driver = webdriver.Chrome()
driver.get("https://tinyjpg.com/")
assert "TinyJPG" in driver.title
droplocation = driver.find_element_by_class_name("icon")
droplocation.click()
autoit = win32com.client.Dispatch("AutoItX3.Control")
autoit.Run(r"filedrop.exe")
However, I got this error:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\win32com\client\dynamic.py", line 89, in _GetGoodDispatch
IDispatch = pythoncom.connect(IDispatch)
pywintypes.com_error: (-2147221021, 'Operation unavailable', None, None)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Tea\Desktop\compressimg.py", line 30, in <module>
autoit = win32com.client.Dispatch("AutoItX3.Control")
File "C:\ProgramData\Anaconda3\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch
dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
File "C:\ProgramData\Anaconda3\lib\site-packages\win32com\client\dynamic.py", line 114, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\ProgramData\Anaconda3\lib\site-packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
pywintypes.com_error: (-2147221164, 'Class not registered', None, None)
The most similar post I could find was this: win32com (python) error, but I think websites are supposed to be COM servers so that's not really relevant here?
In any case, I'm not too sure what the error is trying to tell me, help is appreciated!
reg query HKEY_CLASSES_ROOT\AutoItX3.Control. Run that command at a command prompt. If you get an error then you may need the register the AutoIt DLLs.AutoItX3.dllfor x86 andAutoItX3_x64.dllfor x64. The COM server you mention operates in the OS. You can useregsvr32.exeto register the DLLs if needed.