Question

I want to open notepad and perform some task, but its not opening. i tried this code

import win32com.client
autoit = win32com.client.Dispatch("AutoItX3.Control")
autoit.Run("notepad.exe")

notepad doesn't open but these work fine

autoit.Run("calc.exe")
autoit.Run("explorer.exe")
autoit.Run("regedit")
Was it helpful?

Solution

Try to do something like this:

Open a command prompt window (cmd) as an administrator
Go to AutoItX directory (default on Windows 7 : cd C:\Program Files (x86)\AutoIt3\AutoItX\)
Type these two commands :
regsvr32.exe AutoItX3.dll
regsvr32.exe AutoItX3_x64.dll

Then, try so:

import win32com.client
autoit = win32com.client.Dispatch("AutoItX3.Control")

#Run(program, workingdir, show_flag)
autoit.Run("notepad.exe",'',5)

Description of the parameters for the function Run you can find here. Integer values for parameter show_flag you can find here (5 corresponds SW_SHOW)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top