I have read all of the posts already on this topic but I cannot interact with the "Choose File to Upload" dialog that is used when uploading files with IE8. Basically the problem comes down to the fact that I cannot seem to get a handle to the "Choose File to Upload" window. I am running Selenium and executing a compiled version of my script.
If I write a simple script that just waits for the "Choose File Upload" window and manually make the window show, I can enter the data into the File textbox with no problem.
$hWnd = WinWait("Choose File to Upload")
MsgBox(0,"window handle",$hWnd)
If $hWnd Then
ControlSetText($hWnd,"","Edit1","Test")
ControlClick($hWnd, "", "Button2")
EndIf
here is my code that has a problem:
#include <IE.au3>
If $CmdLine[0] Then
; 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 ; loop through all existing shell windows
if StringInStr($window.LocationURL,"ImportProcessPopup") then
$MyIExplorer=$Window
exitloop
endif
next
; find the Browse Button and Click it
$oFileUpload = _IEGetObjByName ($MyIExplorer, "iFile") ;need iFile to be a param
_IEAction($oFileUpload, "click")
; wait for File Upload dialog to open
$hWnd = WinGetHandle("Choose File to Upload")
; if File Upload dialog opens send the file name and click enter
If $hWnd Then
ControlSetText($hWnd,"","Edit1",$CmdLine[1])
ControlClick($hWnd, "", "Button2")
EndIf
EndIf