2

i am trying to automate a action in notepad for a program im working on and i cant figure out an error message i am getting.

import os
import win32com

object = win32com.client.Dispatch("Notepad.Application")

error

Traceback (most recent call last): File "", line 1, in File "C:\Python27\lib\site-packages\win32com\client__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 104, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 84, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) com_error: (-2147221005, 'Invalid class string', None, None) any help?

1
  • 1
    Are you sure that (1) Notepad is a COM server, and (2) its ProgID is Notepad.Application? Commented Feb 25, 2012 at 19:11

1 Answer 1

3

Notepad has no COM interface that I can Find. Try using pywinauto. Check this video to see how it works.

Sign up to request clarification or add additional context in comments.

1 Comment

@Jon Crawley. If you like the answer, please except it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.