This question has been asked before but I think , the examples have been confusing a bit . Here's my situation :
Script : Python Location : On windows machine "C:\Users\Somedomain\Desktop\Temp\test.py"
Test.py looks like this:
def Fun1(t):
import time
print t.capitalize()
time.sleep(5)
return t.capitalize()
if __name__ == "__main__":
Fun1('arindam')
I can run it from cmd prompt (Ctrl+R), then paste: python C:\Users\inchowar\Desktop\Temp\test.py
AUtoIt Script looks like:
#include <Constants.au3>
$temp = MyFun1()
MsgBox(64, "Result", $temp)
Func MyFun1()
Local $pid = Run('python C:\Users\inchowar\Desktop\Temp\test.py')
if ProcessExists($pid) Then
MsgBox(64, 'Result', 'Its Works..Till here')
$var = StdoutRead($pid)
MsgBox(64, 'Result', $var)
EndIf
ProcessClose($pid)
EndFunc
What i am trying to do here :
I want the output "Arindam" in that MsgBox showing $var .
With the above script , the python script runs , shows output on the shell , then the Main MsgBox shows blank . The 1st msgbox does gets showed up as it pops up successfully , proving that the pid indeed exists.