Sign in to follow this  
Followers 0
Hawkwing

AutoIt and Python StdoutRead

2 posts in this topic

So I'm trying to have AutoIt interact with a compiled Python script using StdoutRead and StdinWrite, but it's a little weird.

This is the Python script that I've compiled to test.exe using py2exe

import time

while 1:
    try:
        print(raw_input())
    except:
        pass
    time.sleep(.05)

and this is the AutoIt code

#include<debug.au3>

HotKeySet('{end}','close')
HotKeySet('{home}','test')

$shell=Run(@MyDocumentsDir & '\Python\test.exe',@WorkingDir,@SW_SHOW,9)
_DebugSetup()
_DebugOut('test.exe')
Sleep(500)
While 1
    Sleep(50)
    $msg=StdoutRead($shell)
    If $msg<>'' Then
        _DebugOut($msg)
    EndIf
Wend

Func test()
    StdinWrite($shell,"this is a test"&@CRLF)
EndFunc

Func close()
    ProcessClose($shell)
    Exit
EndFunc

It looks to me like it should add 'this is a test' to the debug every time I press Home, but it doesn't. It's like it waits till test.exe closes to do anything. If you run it, hit Home a few times, and close the test.exe window, 'this is a test' pops up for however many times you hit Home, but I really don't get why it waits till you close it.

If you run test.exe by itself and type something in, it works as expected.

test.exe


The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Share this post


Link to post
Share on other sites



No one? It really has me confused :)


The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

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