![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | sendkeys, ie7, forms, any new bugs? An automated data query and download download script that has been running well for a year suddenly stopped working recently. Due to (deliberately?)poor coding of the website the only way to fill one input field is sendkeys: Code: Set oDoc = oIE.Document
Set oCollection = oDoc.All.Tags("INPUT")
Set oElement = MatchElementName(oCollection, "uploaded_file")
oElement.Select()
oWsh.AppActivate("Internet Explorer")
oWsh.SendKeys(AVHRR_xml_file)
WScript.Sleep(5000)
oElement.Form.Submit()
it will successfully fill the text input field or leave it blank. Has the recent XP service pack 3 nerfed sendkeys? Has anyone else experienced this? Thanks |
My System Specs![]() |
| | #2 (permalink) |
| | Re: sendkeys, ie7, forms, any new bugs? hi Brendan, I don't know of any "new bugs", but I am surprised that your attempt to just fill in the textbox using the document object model does not work. As you know already, using sendkeys is always problematical. You have to wait until the app is ready to receive keystrokes, and you (sometimes) have to space out the keystrokes to match the apps capability to receive them. The "brute force" solution here would be to vary the timings between appactivate and sending the first keystroke, and also try sending the keystrokes one-at-a-time, with a short delay in-between, and also an appactivate in front of each sendkeys. While this does sound extremely crude, this approach has been successful for me on occasion. As far as using the document object model, I suggest you might go back to that and try different approaches with that too. In the end, the doc object approach is far superior to sendkeys. cheers, jw ____________________________________________________________ You got questions? WE GOT ANSWERS!!! ..(but, no guarantee the answers will be applicable to the questions) Brendan wrote: Quote: > An automated data query and download download script that has been > running well for a year suddenly stopped working recently. Due to > (deliberately?)poor coding of the website the only way to fill one > input field is sendkeys: > Code: > Set oDoc = oIE.Document
> Set oCollection = oDoc.All.Tags("INPUT")
> Set oElement = MatchElementName(oCollection, "uploaded_file")
> oElement.Select()
> oWsh.AppActivate("Internet Explorer")
> oWsh.SendKeys(AVHRR_xml_file)
> WScript.Sleep(5000)
> oElement.Form.Submit()
>
> My routine that matches the element works but now seemingly at random, > it will successfully fill the text input field or leave it blank. Has > the recent XP service pack 3 nerfed sendkeys? Has anyone else > experienced this? > > Thanks |
My System Specs![]() |
| | #3 (permalink) |
| | uh-oh, I forgot something, "focus"... Many -- if not most -- apps will not accept keystrokes into a textbox, unless the textbox has "focus". I don't have any first-hand experience with IE7, but you might experiment (manually) by bringing up the target page, and hitting the tab key until the focus rectangle lands on the textbox where you want to enter your keystrokes. If the focus is not set where you want by the webpage author, then you can get there by using sendkeys and sending tab characters. cheers, jw |
My System Specs![]() |
| | #4 (permalink) |
| | Re: sendkeys, ie7, forms, any new bugs? On Jun 9, 1:51*pm, mr_unreliable <kindlyReplyToNewsgr...@xxxxxx> wrote: Quote: > hi Brendan, I don't know of any "new bugs", but I am surprised > that your attempt to just fill in the textbox using the document > object model does not work. > > As you know already, using sendkeys is always problematical. You > have to wait until the app is ready to receive keystrokes, and > you (sometimes) have to space out the keystrokes to match the > apps capability to receive them. > > The "brute force" solution here would be to vary the timings > between appactivate and sending the first keystroke, and also > try sending the keystrokes one-at-a-time, with a short delay > in-between, and also an appactivate in front of each sendkeys. > While this does sound extremely crude, this approach has been > successful for me on occasion. > > As far as using the document object model, I suggest you might > go back to that and try different approaches with that too. > In the end, the doc object approach is far superior > to sendkeys. > > cheers, jw > ____________________________________________________________ > > You got questions? *WE GOT ANSWERS!!! *..(but, > * * no guarantee the answers will be applicable to the questions) > > > > Brendan wrote: Quote: > > An automated data query and download download script that has been > > running well for a year suddenly stopped working recently. Due to > > (deliberately?)poor coding of the website the only way to fill one > > input field is sendkeys: > > Code: > > Set oDoc = oIE.Document
> > Set oCollection = oDoc.All.Tags("INPUT")
> > Set oElement = MatchElementName(oCollection, "uploaded_file")
> > oElement.Select()
> > oWsh.AppActivate("Internet Explorer")
> > oWsh.SendKeys(AVHRR_xml_file)
> > WScript.Sleep(5000)
> > oElement.Form.Submit()
> >
Quote: > > My routine that matches the element works but now seemingly at random, > > it will successfully fill the text input field or leave it blank. Has > > the recent XP service pack 3 nerfed sendkeys? Has anyone else > > experienced this? Quote: > > Thanks- Hide quoted text - > - Show quoted text - webpage in question (http://www.nsof.class.noaa.gov/saa/products/ upload) has an <input type="file" field. If there is another way to assign a file to this field, other than a sloppy SendKeys, I'd like to know what it is. Thanks, b |
My System Specs![]() |
| | #5 (permalink) |
| | Re: sendkeys, ie7, forms, any new bugs? `Brendan wrote: Quote: Quote: Quote: >>> An automated data query and download download script that has been >>> running well for a year suddenly stopped working recently. Due to >>> (deliberately?)poor coding of the website the only way to fill one >>> input field is sendkeys: > webpage in question (http://www.nsof.class.noaa.gov/saa/products/ > upload) has an <input type="file" field. Secure coding is equivalent to "poor" coding? MS made a much-needed change to IE in order to prevent hackers from automatically stealing personal files from unsuspecting users and you call it "poor" coding ... Well, the "deliberately" part of your description is certainly correct. :-) Since when is a type="file" input used in a download? That type of input is used for choosing files from a user's machine to be uploaded to a web server, not downloaded; and quite rightly, scripts have been prevented from changing the value of those types of inputs. I suppose it is possible that they noticed the loophole that allowed a hacker's script to use Sendkeys to fill in a type="file" input and closed that loophole ... I'm not really sure. I don't have time to go searching the Microsoft and MSDN sites right now for that information, but there is no reason you could not attempt such a search yourself :-) If they did close that loophole, I would expect that they made it harder to get around it than the solution provided by mr_unreliable suggested. -- Microsoft MVP -- ASP/ASP.NET Please reply to the newsgroup. The email account listed in my From header is my spam trap, so I don't check it very often. You will get a quicker response by posting to the newsgroup. |
My System Specs![]() |
| | #6 (permalink) |
| | Re: sendkeys, ie7, forms, any new bugs? On Jun 10, 10:16*am, "Bob Barrows [MVP]" <reb01...@xxxxxx> wrote: Quote: > `Brendan wrote: Quote: Quote: > >>> An automated data query and download download script that has been > >>> running well for a year suddenly stopped working recently. Due to > >>> (deliberately?)poor coding of the website the only way to fill one > >>> input field is sendkeys: > > webpage in question (http://www.nsof.class.noaa.gov/saa/products/ > > upload) has an <input type="file" field. > It would have saved quite a bit of time if you had told us that upfront. > > Secure coding is equivalent to "poor" coding? MS made a much-needed > change to IE in order to prevent hackers from automatically stealing > personal files from unsuspecting users and you call it "poor" coding ... > Well, the "deliberately" part of your description is certainly correct. > :-) > > Since when is a type="file" input used in a download? That type of input > is used for choosing files from a user's machine to be uploaded to a web > server, not downloaded; and quite rightly, scripts have been prevented > from changing the value of those types of inputs. > > I suppose it is possible that they noticed the loophole that allowed a > hacker's script to use Sendkeys to fill in a type="file" input and > closed that loophole ... I'm not really sure. I don't have time to go > searching the Microsoft and MSDN sites right now for that information, > but there is no reason you could not attempt such a search yourself :-) > If they did close that loophole, I would expect that they made it harder > to get around it than the solution provided by mr_unreliable suggested. > > -- > Microsoft MVP -- ASP/ASP.NET > Please reply to the newsgroup. The email account listed in my From > header is my spam trap, so I don't check it very often. You will get a > quicker response by posting to the newsgroup. object which I imagine, in the past, you could simply assign a value. The site in question lets you save and then upload a file with your search parameters. All I wanted to do was automate the pulling of data so that our operator would not have to show up hours early to pull it by hand (large data files). I do not think the site deliberately wants to prevent automated downloads. They let you manually order as many as you want and send an email telling you how to download them using a single ftp command if you do not want to download the files one at a time from their web interface. Anyhow... |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Strange Sendkeys() problem | PowerShell | |||
| Using sendkeys in a web form | VB Script | |||
| Sending Alt-Space with SendKeys in C# | .NET General | |||
| simulate continuous forms & subforms in a windows forms application | .NET General | |||
| SendKeys to cmd.exe | PowerShell | |||