syundiers Posted May 28, 2009 Share Posted May 28, 2009 Hi all, I am trying to auto populate a file upload form on my site, I have declared my variable for the button name and using the code: _IEAction($oButton, "click") the button is clicked and the file dialog box appears, great. The problem is none of my code after this seems to work, i am using send commands to populate the dialog box but it isnt working. I have also tried using the WinWaitActive function but that doesnt seem to work either. No errors appear in my debug box.. Any ideas? thanks Link to comment Share on other sites More sharing options...
oMBRa Posted May 28, 2009 Share Posted May 28, 2009 post some code? Link to comment Share on other sites More sharing options...
syundiers Posted May 28, 2009 Author Share Posted May 28, 2009 Sure sorry.. $oButton = _IEGetObjByName($o_form, "file") _IEAction($obutton, "click") send("c:\hello.jpg") File dialog box pops open but the text isnt sent to it.. I have also tried: $oButton = _IEGetObjByName($o_form, "file") _IEAction($obutton, "click") WinWaitActive("Choose file") send("c:\hello.jpg") But no joy still :/ Link to comment Share on other sites More sharing options...
Juvigy Posted May 28, 2009 Share Posted May 28, 2009 To what are you trying to send that text ? Post some source code of the page please. Link to comment Share on other sites More sharing options...
syundiers Posted May 28, 2009 Author Share Posted May 28, 2009 I am trying to send the file location, once the button is pressed a "choose file" dialog appears when i would normally select the file for upload, i am trying to automatically populate that box with text. <form id="form" enctype="multipart/form-data" action="/upload" method="post"> <input id="form1" name="file" type="file" size="90" /> </form> the dialog box opens fine, but the text doesnt get entered. thanks. Link to comment Share on other sites More sharing options...
Juvigy Posted May 28, 2009 Share Posted May 28, 2009 $oDoc = _IEDocGetObj($oIE) $oArray = $oDoc.getElementsByTagName("input") for $element in $oArray if $element.id="form1" then _IEAction($element, "focus") Send("C:\myfile.txt") endif next Try this one if it works Link to comment Share on other sites More sharing options...
syundiers Posted May 28, 2009 Author Share Posted May 28, 2009 Thanks for your reply. It seems to focus in on the button, but it does not 'get focus' so to speak, and it pastes the text, but in the url box! Link to comment Share on other sites More sharing options...
DaleHohm Posted May 28, 2009 Share Posted May 28, 2009 See example 2 for _IEAction ; Example 2 - Same as Example 1, except instead of using click, give the element focus ; and then use ControlSend to send Enter. Use this technique when the ; browser-side scripting associated with a click action prevents control ; from being automatically returned to your code. Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
syundiers Posted May 28, 2009 Author Share Posted May 28, 2009 Thanks for the help guys. I have tried using the "focus" action, for some reason it just focus'es in on the element but doesnt actually set it as the active object? so it moves the display to it, but the cursor is still in the url bar.. any reason for this? Thanks Link to comment Share on other sites More sharing options...
Juvigy Posted May 28, 2009 Share Posted May 28, 2009 $oDoc = _IEDocGetObj($oIE) $oArray = $oDoc.getElementsByTagName("input") $hwnd = _IEPropertyGet($oIE, "hwnd") for $element in $oArray if $element.id="form1" then _IEAction($element, "focus") ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "C:\myfile.txt") endif next Try this one Link to comment Share on other sites More sharing options...
syundiers Posted May 28, 2009 Author Share Posted May 28, 2009 That seems to have done it! Thankyou so much, this was begining to annoy me! Just out of interest, how come the WinWaitActive("Choose file") doesnt work? even though the open file dialog had the title of "Choose file"? Link to comment Share on other sites More sharing options...
Juvigy Posted May 28, 2009 Share Posted May 28, 2009 I think it works but after that when you use the "send" it doesnt send to the correct window control. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now