Jump to content

Browse for a file from a website


Recommended Posts

Well, I am going around in circles with this. It does not seem to make any sense.

I have written a script that simply opens an IE6 browser, and then clicks a 'Browse' button (opens a browse for file window). I would like to be able to browse for and then select a file and click 'Open'. Unfortunately the script freezes after I have clicked on the 'Browse' button. :)

$oIE = _IECreate ($Environment)
$oForm = _IEFormGetObjByName ($oIE, 'uploadMetadataForm')
$oElement = _IEFormElementGetObjByName ($oForm, 'multiPartFile')
_IEAction($oElement, 'click')

; This is where my script freezes

send('Z:\RadconDeliveries\CLS_TestData\RACOT27\metadata\ELS_RC_MET_RACOT27A.zip')
send('{ENTER}')
sleep(500)

I have added 'opt('TrayIconDebug', 1)' to the beggining of my script and it tells me that it is stuck on IE.au3 line 453 which is 'sleep(100). This line of code appears in the _IELoadWait() function. I find it odd that this function is called as it does not seem to be from the _IEAction function.

I am not a programmer, so am I mising something? :)

Appreciate any help or suggestions you may have.

Link to comment
Share on other sites

Why do you send the address? Why not just create it?

I am not sure that that is the real issue here. I do not really care whether I 'create' the file name or not. My real issue is that the script freezes and I am unsure why. I think - (not usually a good thing :) ) that it is because the focus is taken away from the IE instance. I have not done this before with other scripts...

Thanks for your original reply...but if you can answer this, I'll love you forever ;-)

Link to comment
Share on other sites

You say you "click the Browser button" -- is $oElement the browser button? What happens when click it? Does a file selection form appear?

If this is the case, then yes, your AutoIt script will pause waiting for the return of the dialog and other commands will not be processed.

You are almost there... instead of using _IEAction($oElement, 'click') use _IEAction($oElement, 'focus') and then SEND('{ENTER}')

This will activate the button with simulated keyboard action and allow your script to continue because it isn't tied into the .click method event processing.

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

You are almost there... instead of using _IEAction($oElement, 'click') use _IEAction($oElement, 'focus') and then SEND('{ENTER}'

Dale

I am going to give this a bash now...if it works, I owe you a beer ;-)

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...