<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"Lucida Sans Typewriter";
        panose-1:2 11 5 9 3 5 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=EN-AU link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>[apologies for top post]<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>All there is to know about os.startfile() is in Python’s
docs. The only way to achieve the effect you desire is to do what the “Start
Menu...” action does – explicitly open an instance of the application
(and not all applications will open new instances; some will always open an
existing instance if one exists).<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>You don’t state what version of Python you’re using.
Assuming it is at least 2.6, you may wish to investigate the subprocess module
and possibly the multiprocessing module. You will have to explicitly
identify the application required to open the file, as you would with
os.system().<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>If the application you wish to run supports COM (such as MS
Word/Excel etc do), you could try PythonWin or comtypes, either of which will
give much more control such as saving the file and exiting cleanly.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Other than COM, application automation on Windows requires
Windows API programming to send the necessary messages to application windows –
this is what AutoIt does. I believe that people have written Python code
to do this; googling “python application automation” might give you
some ideas.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Sans Typewriter";
color:#1F497D'>-------------------------> "These thoughts are mine
alone!" <---------<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Sans Typewriter";
color:#1F497D'>Andrew
MacIntyre
Operations Branch<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Sans Typewriter";
color:#1F497D'>tel: +61 2 6219 5356 Communications
Infrastructure Division<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Sans Typewriter";
color:#1F497D'>fax: +61 2 6253 3277
Australian Communications & Media Authority<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Sans Typewriter";
color:#1F497D'>email: <a href="mailto:andrew.macintyre@acma.gov.au">andrew.macintyre@acma.gov.au</a>
<a href="http://www.acma.gov.au/">http://www.acma.gov.au/</a><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<div style='border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt'>
<div>
<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'>
<p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:
"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;
font-family:"Tahoma","sans-serif"'>
python-win32-bounces+andrew.macintyre=acma.gov.au@python.org
[mailto:python-win32-bounces+andrew.macintyre=acma.gov.au@python.org] <b>On
Behalf Of </b>Tony Cappellini<br>
<b>Sent:</b> Friday, 4 February 2011 7:52 AM<br>
<b>To:</b> python-win32@python.org<br>
<b>Subject:</b> [python-win32] Using os.startfile() for automation<o:p></o:p></span></p>
</div>
</div>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal style='margin-bottom:12.0pt'><br>
<br>
On Windows XP, I'm able to launch the application associated with file1.xxx.<br>
<br>
os.startfile("file1.xxx")<br>
<br>
I want to start more instances of the application, so that I can process
several files at the same time.<br>
<br>
calling os.startfile("file2.xxx") causes the instance of the
application to also open file2.xxx.<br>
<br>
The problem with this is- I have to wait until file1 has finished processing,
before I can start file2.<br>
<br>
If, after opening the first instance for file1, I can use the Start Menu,
Program Files, open another instance of the application, I can then start<br>
processing file2 at the same time as file1, but using a separate instance.<br>
<br>
Is there any other way to invoke startfile() or other function- to force a new
instance of the application to open?<br>
<br>
How would I close the application from Python, that was started with
os.startfile()?<br>
<br>
<br>
Once the application is open, I just want to use File Save As Text, to get the
data into a text file.<br>
Python's app-automation capabilities are kinda weak and not well documented, so
I may resort to AutoIt3.<br>
<br>
Thanks<br>
<br>
<br>
<o:p></o:p></p>
</div>
</div>
<P>NOTICE: This email message is for the sole use of the intended recipient(s) <br/>
and may contain confidential and privileged information. Any unauthorized <br/>
review, use, disclosure or distribution is prohibited. If you are not the <br/>
intended recipient, please contact the sender by reply email and destroy all <br/>
copies of the original message.
</P></body>
</html>