SirGarry32 Posted June 1, 2010 Posted June 1, 2010 Hello, I'm having a problem trying to write to my Python script.I am perfectly able to receive output from Python, but I just can't seem to make an input!Here is my code:$Process = run("python io-test.py",@ScriptDir,@SW_HIDE,0x3) ProcessWait("python.exe") TrayTip("Success","Success!",10) While 1 StdinWrite($Process,"Hello, Python.") TrayTip("StdOut",StdoutRead($Process),10) Sleep(1000) WEndwhile 1: string = input(">") print(string)The tray tip, that should contain "Hello, Python.", only contains ">"! (which is the prompt from input(">"))Someone please help, or I may cry.
jaberwacky Posted June 1, 2010 Posted June 1, 2010 When you Run() a process, the script pauses until the process has exited. So you're writing to a process that no longer exists. That's my initial thought anyway. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum?
zorphnog Posted June 1, 2010 Posted June 1, 2010 (edited) When you Run() a process, the script pauses until the process has exited. So you're writing to a process that no longer exists. That's my initial thought anyway. Run() is not a blocking function as you are suggesting. RunWait() behaves in the way you are describing. Try this: $Process = run("python io-test.py",@ScriptDir,@SW_SHOW,0x3) ProcessWait("python.exe") TrayTip("Success","Success!",10) StdinWrite($Process,"Hello, Python.") While 1 $sLine = StdoutRead($Process) If @error Then ExitLoop TrayTip("StdOut", $sLine,10) Sleep(1000) WEnd Edit: Use @SW_SHOW so you can see whether the text is being written to the python console. Edited June 1, 2010 by zorphnog
SirGarry32 Posted June 1, 2010 Author Posted June 1, 2010 (edited) . Edited June 1, 2010 by SirGarry32
SirGarry32 Posted June 1, 2010 Author Posted June 1, 2010 (edited) Try this: $Process = run("python io-test.py",@ScriptDir,@SW_SHOW,0x3) ProcessWait("python.exe") TrayTip("Success","Success!",10) StdinWrite($Process,"Hello, Python.") While 1 $sLine = StdoutRead($Process) If @error Then ExitLoop TrayTip("StdOut", $sLine,10) Sleep(1000) WEnd Edit: Use @SW_SHOW so you can see whether the text is being written to the python console. Still only outputs ">". :-( And the Python console isn't showing anything. Edited June 1, 2010 by SirGarry32
Xand3r Posted June 1, 2010 Posted June 1, 2010 python might be waiting for a @CRLF like c/c++ so try StdinWrite($Process,"Hello, Python." & @crlf) Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro
SirGarry32 Posted June 2, 2010 Author Posted June 2, 2010 (edited) python might be waiting for a @CRLF like c/c++ so try StdinWrite($Process,"Hello, Python." & @crlf)Oh my god, it works! I hate it when the solutions to my problems are so simple.Thanks for the help guys. Edited June 2, 2010 by SirGarry32
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now