Jump to content

Run Python File From Autoit


Krikov
 Share

Recommended Posts

Hello,

did any one try ever to run Python Script From Autoit

My Problem is to Run an Python Script With Two Parameters that i read from 2 Input Box

when i run the script i get "File Not Found"

Python Code

import sys;
import glob;
import os;

dirs = [];

def listFiles( outFile, path ):
    files = glob.glob( path + "\\*" );
    for f in files:
        sys.stderr.write( f + "\n" );
        if os.path.isfile( f ):
            outFile.write( f + "\n" );
        if os.path.isdir( f ):
            dirs.append( f );
          
def main( argv ):
    FROM_PARAM_INDEX = 1;
    TO_PARAM_INDEX = 2;

    LIST_FROM = argv[FROM_PARAM_INDEX];
    LIST_TO = argv[TO_PARAM_INDEX];

    dirs.append( LIST_FROM );
    outFile = file( LIST_TO, "w" );
    while ( len(dirs) > 0 ):
        dir = dirs.pop( 0 );
        listFiles( outFile, dir );
    outFile.close();    

if __name__ == "__main__":
    sys.exit( main( sys.argv ) );

And This is The Run Command

RunWait("ListFile.py "&(GUICtrlRead($Input1))&" "&(GUICtrlRead($Input2)))
The system cannot find the file specified.

[topic="63488"][font="Arial"]Krikov Tray Quick Menu[/font][/topic]

Link to comment
Share on other sites

Hello,

did any one try ever to run Python Script From Autoit

My Problem is to Run an Python Script With Two Parameters that i read from 2 Input Box

when i run the script i get "File Not Found"

Python Code

import sys;
import glob;
import os;

dirs = [];

def listFiles( outFile, path ):
    files = glob.glob( path + "\\*" );
    for f in files:
        sys.stderr.write( f + "\n" );
        if os.path.isfile( f ):
            outFile.write( f + "\n" );
        if os.path.isdir( f ):
            dirs.append( f );
          
def main( argv ):
    FROM_PARAM_INDEX = 1;
    TO_PARAM_INDEX = 2;

    LIST_FROM = argv[FROM_PARAM_INDEX];
    LIST_TO = argv[TO_PARAM_INDEX];

    dirs.append( LIST_FROM );
    outFile = file( LIST_TO, "w" );
    while ( len(dirs) > 0 ):
        dir = dirs.pop( 0 );
        listFiles( outFile, dir );
    outFile.close();    

if __name__ == "__main__":
    sys.exit( main( sys.argv ) );

And This is The Run Command

RunWait("ListFile.py "&(GUICtrlRead($Input1))&" "&(GUICtrlRead($Input2)))
The system cannot find the file specified.
The runwait is probably looking for a path in front of "ListFile.py"

Also look in the help file for ShellExecuteWait. It may work better for you.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Thanks But

when i try the ShellExecuteWait i still get the same error

The system cannot find the file specified.

the only way that i waz sucessed to run the Python script is with _RunDos but this is not very good for me cuz when i try to select

a folder with Hebrew Characters the Dos Windows Show me gibberish font and the script not running so i must solve it with RunWait or ShellExecuteWait

Krikov

[topic="63488"][font="Arial"]Krikov Tray Quick Menu[/font][/topic]

Link to comment
Share on other sites

Thanks But

when i try the ShellExecuteWait i still get the same error

The system cannot find the file specified.

the only way that i waz sucessed to run the Python script is with _RunDos but this is not very good for me cuz when i try to select

a folder with Hebrew Characters the Dos Windows Show me gibberish font and the script not running so i must solve it with RunWait or ShellExecuteWait

Krikov

Did You check for the path to the file?

If it's in the same folder as the au3 file then you could use

RunWait(@ScriptDir & "\ListFile.py "&(GUICtrlRead($Input1))&" "&(GUICtrlRead($Input2)))

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

  • 3 years later...

Hello, i am having the same problem of not able to run python in Autoit..

the scenario is that i have a script at C:\Python25\ and the python script is Audio_Play.py which takes argument of filename to play like sound.mp3

so the Command i use in normal window run is :

C:\Python25\Audio_Play.py sound.mp3

how can this be called in Autoit??

and also is it possible to return a value from called python function to autoit ?

Thanks nd Regards

Link to comment
Share on other sites

Hello, i am having the same problem of not able to run python in Autoit..

the scenario is that i have a script at C:\Python25\ and the python script is Audio_Play.py which takes argument of filename to play like sound.mp3

so the Command i use in normal window run is :

C:\Python25\Audio_Play.py sound.mp3

how can this be called in Autoit??

and also is it possible to return a value from called python function to autoit ?

Thanks nd Regards

Hi first of all you can try to complie the PY File to EXE like PY2EXE take a look at this link :http://www.ehow.com/how_2091641_compile-python-code.html

or try to use the Pyton.exe Audio_Play.py sound.mp3

and the Autoit Command will :

$Run = RunWait("C:\Pyton25\Pyton.exe Audio_Play.py sound.mp3","")

Krikov

Edited by Krikov

[topic="63488"][font="Arial"]Krikov Tray Quick Menu[/font][/topic]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...