I have a Python (.py) file and need to execute it from AutoIt. How can I do this?
解决方案
Python scripts can be executed from command line. For a script called myscript.py, you can run it (assuming Python is installed) by typing:
python myscript.py
If you want to run myscript.py without having to prefix it by python, then set the path to the Python binary (e.g. C:\Python27\Python.exe) as Windows environment variable. This enables AutoIt to execute the Python script as if it were an external program. Reference: ShellExecute().
ShellExecute("myscript.py")
Point to where myscript.py resides of course. Use:
RunWait("C:\Python27\Python.exe myscript.py")
to avoid setting environment variables.