Jump to content

How to deal with IE window for upload a file(input type="file")


xjiang
 Share

Recommended Posts

Hi, All

There's a element in the web:

<input id="fileInput_iPhoneandiPodtouchScreenshots" type="file" name="filedata" class="lcUploadFile" style="">

first, I use the below script, the result is paused in line 2 and the script can't continue:

Local $oSubmit = _IEGetObjById($oIE, "fileInput_iPhoneandiPodtouchScreenshots")
_IEAction($oSubmit, "click")
Local $sWindowTitle = "File Upload"
WinWaitActive($sWindowTitle)
If WinActive($sWindowTitle,"") Then
ControlSetText($sWindowTitle,"","Edit1","D:\Autoit\iPhone and iPod touch Screenshots\screenshot5.jpg")
ControlClick($sWindowTitle,"","Button1")
EndIf

so, I tried another way. I made an Autoit EXE named "PopUpHandler.exe" with the script:

Local $sWindowTitle = "File Upload"
WinWaitActive($sWindowTitle)
If WinActive($sWindowTitle,"") Then
ControlSetText($sWindowTitle,"","Edit1","D:\Autoit\iPhone and iPod touch Screenshots\screenshot5.jpg")
ControlClick($sWindowTitle,"","Button1")
EndIf

it can worked well when i run it directly. But if I call it in the main script, it doesn't work.

;ShellExecute("PopUpHandler.exe", $sFile, @ScriptDir, "open", @SW_HIDE) ;doesn't work too.
Run("PopUpHandler.exe",@ScriptDir,@SW_HIDE,$STDOUT_CHILD)
Local $oSubmit = _IEGetObjById($oIE, "fileInput_iPhoneandiPodtouchScreenshots")
_IEAction($oSubmit, "click")

The PopUpHandler.exe has done its work, but the web($oIE) report a error. You can check it in the attach.

so, my questions is:

1. Why PopUpHandler.exe can work when run it directly, but can't work in another script?

2. Do we have another mothed to deal with this input type="file"?

Thanks.

post-75862-0-52655500-1351155160_thumb.j

Edited by xjiang
Link to comment
Share on other sites

See my sig for alternatives.

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

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...