Sign in to follow this  
Followers 0
Krikov

Run Python File From Autoit

9 posts in this topic

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]

Share this post


Link to post
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!"

Share this post


Link to post
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]

Share this post


Link to post
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!"

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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]

Share this post


Link to post
Share on other sites

thanks for the reply..

i tried to using py2exe but its still not working.. normally on command prompt its running fine.. but wen i try it using Autoit i'm not able to..

wat might be the problem??

Share this post


Link to post
Share on other sites

other .exe files are running but no luck with .exe of python from py2exe.

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

and also the above command is also not working. :)

Share this post


Link to post
Share on other sites

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

If that's a cut & paste from your script*, the missing 'h's might be a problem.

William

* as opposed to typos if you typed it directly into the forum

Share this post


Link to post
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
Sign in to follow this  
Followers 0