Re: Use python to execute a windows program

2009-09-11 Thread Jerry Hill
On Fri, Sep 11, 2009 at 3:31 PM, Doran, Harold  wrote:
> Thanks, Jerry. Tried that, as well as various other possible names to no
> avail.

You'll need to dig into the documentation then, probably starting in
one of these two places:
http://pywinauto.openqa.org/howto.html
http://pywinauto.openqa.org/module-pywinauto.application.html

The howto says that once you've started your application, calling
app.windows_() will return a list of visible, enabled, top level
windows of the application.  Try printing those and seeing if any of
them look like the window you want.  Or maybe try app.top_window_()
which tries to guess which window might be the "main" window of your
application.

-- 
Jerry
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Use python to execute a windows program

2009-09-11 Thread Doran, Harold
Thanks, Jerry. Tried that, as well as various other possible names to no
avail. 

> -Original Message-
> From: python-list-bounces+hdoran=air@python.org 
> [mailto:python-list-bounces+hdoran=air@python.org] On 
> Behalf Of Jerry Hill
> Sent: Friday, September 11, 2009 3:09 PM
> To: python-list@python.org
> Subject: Re: Use python to execute a windows program
> 
> On Fri, Sep 11, 2009 at 12:46 PM, Doran, Harold 
>  wrote:
> > I am working with this now. I'm toying with the examples to 
> test out a 
> > few things and learn how this works. I've made some 
> modifications such 
> > that I have the following working (below). This does 
> nothing more than 
> > open a program.
> >
> > I have commented out the portion
> >
> > #app.AM.MenuSelect("File->Open Database")
> >
> > When it is uncommented, the program fails. However, when I 
> tinker with 
> > this MenuSelect() for, say, Notepad, this presents no problem and 
> > behaves as expected. For example, the following works with notepad:
> >
> > app.Notepad.MenuSelect("Help->Help Topics")
> >
> > At the risk of sounding too silly, how do I know what to 
> place after 
> > app.??.MenuSelect? I've tried this with a few programs and 
> the name I 
> > use in place of ?? Doesn't seem to work.
> 
> I'm not very familiar with pywinauto myself, but a quick look 
> through the docs says that the application looks for a window 
> or dialog with a "similar" name to what you put there.  So, 
> what does the title bar of the window opened by AM.exe say?  
> You should use a name that is "similar" to the title of the 
> window you're trying to control.
> 
> --
> Jerry
> --
> http://mail.python.org/mailman/listinfo/python-list
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Use python to execute a windows program

2009-09-11 Thread Jerry Hill
On Fri, Sep 11, 2009 at 12:46 PM, Doran, Harold  wrote:
> I am working with this now. I'm toying with the examples to test out a
> few things and learn how this works. I've made some modifications such
> that I have the following working (below). This does nothing more than
> open a program.
>
> I have commented out the portion
>
> #app.AM.MenuSelect("File->Open Database")
>
> When it is uncommented, the program fails. However, when I tinker with
> this MenuSelect() for, say, Notepad, this presents no problem and
> behaves as expected. For example, the following works with notepad:
>
> app.Notepad.MenuSelect("Help->Help Topics")
>
> At the risk of sounding too silly, how do I know what to place after
> app.??.MenuSelect? I've tried this with a few programs and the name I
> use in place of ?? Doesn't seem to work.

I'm not very familiar with pywinauto myself, but a quick look through
the docs says that the application looks for a window or dialog with a
"similar" name to what you put there.  So, what does the title bar of
the window opened by AM.exe say?  You should use a name that is
"similar" to the title of the window you're trying to control.

-- 
Jerry
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Use python to execute a windows program

2009-09-11 Thread Doran, Harold
I am working with this now. I'm toying with the examples to test out a
few things and learn how this works. I've made some modifications such
that I have the following working (below). This does nothing more than
open a program.

I have commented out the portion

#app.AM.MenuSelect("File->Open Database")

When it is uncommented, the program fails. However, when I tinker with
this MenuSelect() for, say, Notepad, this presents no problem and
behaves as expected. For example, the following works with notepad:

app.Notepad.MenuSelect("Help->Help Topics")

At the risk of sounding too silly, how do I know what to place after
app.??.MenuSelect? I've tried this with a few programs and the name I
use in place of ?? Doesn't seem to work.




import time
import sys

try:
from pywinauto import application
except ImportError:
import os.path
pywinauto_path = os.path.abspath(__file__)
pywinauto_path = os.path.split(os.path.split(pywinauto_path)[0])[0]
import sys
sys.path.append(pywinauto_path)
from pywinauto import application


def AM():

app = application.Application()

try:
app.start_(   # connect_(path =
ur"C:\Program Files\American Institutes for
Research\AMBeta\AM.exe")
except application.ProcessNotFoundError:
print "You must first start Windows Media "\
"Player before running this script"
sys.exit()

 #app.AM.MenuSelect("File->Open Database")
 

def Main():
start = time.time()

AM()

if __name__ == "__main__":
Main() 

> -Original Message-
> From: simon.brunn...@gmail.com 
> [mailto:simon.brunn...@gmail.com] On Behalf Of Simon Brunning
> Sent: Friday, September 11, 2009 11:02 AM
> To: Doran, Harold
> Cc: python-list@python.org
> Subject: Re: Use python to execute a windows program
> 
> 2009/9/11 Doran, Harold :
> > The way we do this now is a person sits in front of their 
> machine and 
> > proceeds as follows:
> >
> > 1) Open windows program
> > 2) Click file -> open which opens a dialog box
> > 3) Locate the file (which is a text file) click on it and let the 
> > program run.
> 
> It might very well be possible, depending upon how the 
> program you want to automate has been written.
> 
> First, make sure, absolutely sure, that's there's no "proper"
> automation option available - a command line version, COM 
> automation, that kind of thing. These approaches are very 
> much easier than GUI automation.
> 
> If none of these options are available, 
> <http://pywinauto.openqa.org/> is probably what you need.
> 
> --
> Cheers,
> Simon B.
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Use python to execute a windows program

2009-09-11 Thread Alan G Isaac

Does the Windows application offer a COM interface?
http://oreilly.com/catalog/pythonwin32/chapter/ch12.html
http://sourceforge.net/projects/pywin32/

Alan Isaac

--
http://mail.python.org/mailman/listinfo/python-list


Re: Use python to execute a windows program

2009-09-11 Thread Simon Brunning
2009/9/11 Doran, Harold :
> The way we do this now is a person sits in front of their machine and
> proceeds as follows:
>
> 1) Open windows program
> 2) Click file -> open which opens a dialog box
> 3) Locate the file (which is a text file) click on it and let the
> program run.

It might very well be possible, depending upon how the program you
want to automate has been written.

First, make sure, absolutely sure, that's there's no "proper"
automation option available - a command line version, COM automation,
that kind of thing. These approaches are very much easier than GUI
automation.

If none of these options are available, 
is probably what you need.

-- 
Cheers,
Simon B.
-- 
http://mail.python.org/mailman/listinfo/python-list