<br><font size=2 face="sans-serif">Thanks for the tip Vernon. It
plays very nicely with the win32 module. Just set the focus on the form
element you want to control before sending the input text.</font>
<br>
<br><font size=2 face="sans-serif">Here's what worked for me. It's painless:</font>
<br><font size=2 face="sans-serif">=========================</font>
<br>
<br><font size=2 face="sans-serif">from win32com.client import DispatchEx</font>
<br><font size=2 face="sans-serif">import WindPySend as W</font>
<br>
<br><font size=2 face="sans-serif">ie = DispatchEx('InternetExplorer.Application')</font>
<br><font size=2 face="sans-serif">ie.Navigate("file://C:/myhtml.html")</font>
<br><font size=2 face="sans-serif">ie.Visible = 1</font>
<br>
<br><font size=2 face="sans-serif">myfilebox = ie.Document.forms[0].elements.all["file_1"]</font>
<br><font size=2 face="sans-serif">myfilebox.focus()</font>
<br><font size=2 face="sans-serif">W.send("C:\mydir\myfile.txt")</font>
<br><font size=2 face="sans-serif"><br>
Paul S. Johnson<br>
</font>
<br><font size=2><tt>Vernon Cole <> wrote on 08/17/2004 09:36:39
AM:<br>
<br>
> Check out http://users.swing.be/wintclsend/windpysend/ . <br>
> Windpysend is a package which will emulate typing and/or mouse <br>
> clicks on another window. Vincent (the author) charges a modest <br>
> license fee for this. I am hoping that someone will make a good <br>
> donation to him so that he will release the source. It is a very <br>
> handy function for a scripting language to have.</tt></font>
<br><font size=2><tt>> ----------</tt></font>
<br><font size=2><tt>> Vernon</tt></font>
<br><font size=2><tt>> </tt></font>
<br><font size=2><tt>> -----Original Message-----<br>
> From:Paul S. Johnson [mailto:]<br>
> Sent: Tuesday, August 17, 2004 7:33 AM<br>
> To: python-win32@python.org<br>
> Cc: Ludovic Reenaers<br>
> Subject: Re: [python-win32] Controlling IE file input boxes<br>
</tt></font>
<br><font size=2><tt>> <br>
> "Ludovic Reenaers" wrote on 08/17/2004 02:52:07 AM:<br>
> <br>
> > MAy be try this:<br>
> > from win32com.client import DispatchEx<br>
> > <br>
> > ie = DispatchEx('InternetExplorer.Application')<br>
> > ie.Navigate("file://C:/myhtml.html")<br>
> > ie.Visible = 1<br>
> > myfilebox = ie.Document.forms[0].elements.all["file_1"]<br>
> > [myfilebox.Value='c:\\xx\\xx.txt'] OR [myfilebox.Value('c:\\xx\\xx.txt')]<br>
> > It should be possible that kind of way.<br>
> > <br>
> > Ludo<br>
> <br>
> I wish it was as simple as that. For INPUT tags of where type=FILE,
<br>
> the Value attribute is read-only. I can fetch a value that was <br>
> manually input by the user, but I cannot set it. This, I suppose,
is<br>
> for security reasons so evil web programmers cannot go phishing for
<br>
> files on the user's hard drive. <br>
> <br>
> > <br>
> > We are testing a web site we are developing by controlling
IE through<br>
> > > Python and need to be able to input the value of an INPUT
tag where<br>
> > > TYPE=FILE. I understand the security concern of MS
not allowingthis, but<br>
> > > isn't there some way around it? The python code below
initiates the<br>
> > > windows file dialog (what happens when someone clicks the
"browse" button<br>
> > > of the file input box). Is there anyway to script
through this and input<br>
> > > a file name?<br>
> > ><br>
> > > ===============================<br>
> > > HTML:<br>
> > ><br>
> > > <html><br>
> > > <head><br>
> > > <title>My Site</title><br>
> > > </head><br>
> > > <body><br>
> > > <form name="myform" action=""
method="post"><br>
> > > <input type="file" name="file_1"
value="Pick Me"><br><br>
> > > </form><br>
> > > </body><br>
> > > </html><br>
> > > ===============================<br>
> > > Python code:<br>
> > ><br>
> > > from win32com.client import DispatchEx<br>
> > ><br>
> > > ie = DispatchEx('InternetExplorer.Application')<br>
> > > ie.Navigate("file://C:/myhtml.html")<br>
> > > ie.Visible = 1<br>
> > > myfilebox = ie.Document.forms[0].elements.all["file_1"]<br>
> > > myfilebox.click()<br>
> > > #??? now what???<br>
> > > ================================<br>
> > ><br>
> > > Paul Johnson<br>
> > > _______________________________________________<br>
> > > Python-win32 mailing list<br>
> > > Python-win32@python.org<br>
> > > http://mail.python.org/mailman/listinfo/python-win32<br>
> > ><br>
> > </tt></font>