Jump to content

Upload file issue in IE


Recommended Posts

Hi Guys,

I am new to autoit.I am trying to upload a file as follows.Click on Browse button >select path of file to be uploaded and click on open.

What happens here is code gets executed till clicking browse button but after that, choose file titled window is not recognized.Code I have used is

#include <IE.au3>

; Internet Explorer is partly integrated in shell.application

$oShell = ObjCreate("shell.application") ; Get the Windows Shell Object

$oShellWindows=$oShell.windows ; Get the collection of open shell Windows

$MyIExplorer=""

for $Window in $oShellWindows ; Count all existing shell windows

; Note: Internet Explorer appends a slash to the URL in it's window name

if StringInStr($window.LocationURL,"http://URL.jsp") then

$MyIExplorer=$Window

exitloop

endif

next

$oForm = _IEGetObjByName ($MyIExplorer, "alfFileInput")

_IEAction($oForm, "click")

;Here after code is not getting executed

WinWaitActive("Choose file")

Send("C:\d.bmp")

Send("{ENTER}")

Note:-After command "_IEAction($oForm, "click")"...system keeps the "choose file "titled window opened to select path of file and click on open.But system does not recognize choose file titled window to select file and does not write file path in browse button text area.In short path of file to be written is not recognized(whole window I can say ).

Interesting thing is if I cancel this window and again clicks on browse button ,then automatically system writes path in text area of browse and clicks on open and uploads the file.Same thing happens when code till command "_IEAction($oForm, "click")" and after this command are made into separate exe files and run.

Please help me out in resolving this issue.Also please give me some clarity how these shell windows are calculated.Its urgent please.

I want to click on browse button,select path >open and see uploaded file in the page.

Edited by vamsikrishna
Link to comment
Share on other sites

#include <IE.au3>
; Internet Explorer is partly integrated in shell.application
$oShell = ObjCreate("shell.application") ; Get the Windows Shell Object
$oShellWindows = $oShell.windows ; Get the collection of open shell Windows
$MyIExplorer = ""
For $Window In $oShellWindows ; Count all existing shell windows
    ; Note: Internet Explorer appends a slash to the URL in it's window name
    If StringInStr($window.LocationURL, "http://URL.jsp") Then
        $MyIExplorer = $Window
        ExitLoop
    EndIf
Next
$oForm = _IEGetObjByName($MyIExplorer, "alfFileInput")
_IEAction($oForm, "click")
;Here after code is not getting executed
WinWaitActive("Choose file")
Send("C:\d.bmp")
Send

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

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