running script from command line

Help
Stefaan
2006-03-22
2013-05-28
  • Stefaan

    Stefaan - 2006-03-22

    Hello,

    Second problem I encountered was when I tried to run an automation script from the command line cmd.exe:

    My script first starts up an application using the start_ call, then sends mouse clicks and keys to it.

    If I run the automation script from the command line with:
    python.exe myscript.py
    The "Dos window" disappears as soon as the application has started, and no further events are sent to the application (or received by the application). The application just starts up and waits for user interaction.

    If I run the automation script from the command line with:
    pythonw.exe myscript.py
    The "Dos window" also disappears as soon as the application has started, but at least the events are still sent to the application. Unfortunately all logging that is sent to stderr or stdout is not visible. tkMessageBoxes OTOH are shown without problem.

    Running the script from IDLE works like a charm.

    Any ideas?

    Thanks in advance,
    Stefaan.

    p.s. python 2.4, pywinauto 0.3.0, win2000

     
    • Mark Mc Mahon

      Mark Mc Mahon - 2006-03-22

      Hi,

      This is weird!  You mention tkMessageBoxes - are these done with Python? I wonder if there is any conflict between the two python interpreters running at once?

      I have never seen the issue you talk about - I run from the command line all the time. (in fact I haven't used IDLE at all!)

      It seems (though this is just a guess) when running python.exe - the window stays open - but your pywinauto closes it (and thus kill's itself!). But when running pythonw.exe - no window is created - so your pywinauto script cannot close it.

      Just on a side note - I am Europe this and next week - so I won't be responsive after 10:00 pm my time.

      I know I haven't been much help - but I am not sure that it is pywinauto that is the root cause of these issues (though if it is I will do my best to fix it!).

      Thanks
        Mark

       
    • Stefaan

      Stefaan - 2006-03-22

      tkMessageBox is part of Tkinter, the platform independent GUI library that is shipped with all python versions.

      Tkinter in itself is a wrapper around tcl/tk. Python normally works very well with Tkinter (it ships with it).

      Could it be related to some of the parameters you pass to the CreateProcess command? Maybe these should be slightly different in win2000 than on winxp? I do not have too much experience with windows based systems, normally being a linux user.

      My time to work on this is rather limited, but
      I hope I will find some time to dig further.

      Thanks.
      Stefaan.

       
      • Mark Mc Mahon

        Mark Mc Mahon - 2006-03-23

        Hi Stefaan,

        I was more worried about Pywinauto's and your app's python interpreters messing with each other.

        If you need to get this working in a short time it sounds like you should change Click() to ClickInput() and instead of app.dlg.editcontrol.TextBlock() you do:
        #CTRL+A, CTRL+C to copy all text
        app.dlg.editcontrol.TypeKeys("^A^C")
        value = pywinauto.clipboard.GetData()
        # convert to int/float etc - though not sure if you need this
        value = eval(value)

        If you are worried about pywinauto starting the application - then you can start it yourself and "connect" to it using pywinauto (rule that out at least!) Though I doubt that is the problem.

        Hope this helps
        Mark

         
    • Stefaan

      Stefaan - 2006-03-23

      Ok this problem is accounted for. Apparantly the application kills all running cmd.exe processes while starting up *rolling eyes*.

      Thanks.

       

Log in to post a comment.