I think I have an issue with IEGet and IE dialog boxes. I have a script that monitors a folder for csv files. Once it finds one or more files, the script is supposed to login to a web app and then for each file, it has to click the browse button to upload the selected file and wait for it to finish being processed and repeat. My issue is that my code stops as soon as the "choose file to upload" dialog is opened. At this point, I want to sendinput the string that is the path to the selected file and click the "Open" button.
Code below:
Code: Select all
#Persistent
#SingleInstance Force
SetTitleMatchMode 2
wb := IEGet("Supply Chain Online")
SetTimer, MonitorForFiles2, 15000
return
MonitorForFiles2:
fileSource := "B:\xxx\"
fileDestination := "B:\xxx\old\"
fileCount := ComObjCreate("Scripting.FileSystemObject").GetFolder(fileSource).Files.Count
if(fileCount > 0)
{
SetTimer, MonitorForFiles2, off
WinActivate, Internet Explorer
WinMaximize, Internet Explorer
sleep, 5000
wb.visible := true
;click checkbox
Click 790, 215
sleep 3000
;click login button
wb.Document.All.Submit1.Click()
sleep 3000
;click tab
Click 360, 177
;loop through the files found
Loop, %fileSource%\*.csv, , 0
{
csvfile := fileSource A_LoopFileName
sleep 5000
;click browse button
upLoadFile:
wb.Document.All.fupdTech.Click()
;Click 575, 343
;WinWaitActive, Choose File to Upload
;send file path and name to the browse dialog box
SendInput, %csvfile%
;click 249, 197
sleep, 500
;click the open button
Click 625, 565
WinWaitClose, Choose File to Upload
sleep 2000
;click upload button
Click 660, 340
loop 600
{
if((StrLen(wb.document.getElementById("lblerror").innerHTML)>0) or (StrLen(wb.document.getElementById("jGridTable").Rows.length)>0))
{
break
}
else{
sleep 1000
}
}
errorString := ""
if(StrLen(wb.document.getElementById("lblerror").innerHTML)>0)
{
errorString := wb.document.getElementById("lblerror").innerHTML
}
errorMsg = Error occurred in reading the contents of file
IfInString errorString, %errorMsg%
{
counter := counter + 1
if(counter < 3)
{
sleep 2000
goto upLoadFile
}
}
;move file to archive folder
if FileExist(csvfile)
{
FileMove, %csvfile%, %fileDestination%,1
}
}
sleep 3000
SetTimer, MonitorForFiles2, on
;click log off button
Click 952, 84
}
else{
return
}
;open
IEGet(Name="")
{
IfEqual, Name,, WinGetTitle, Name, ahk_class IEFrame
Name := ( Name="New Tab - Windows Internet Explorer" ) ? "about:Tabs"
: RegExReplace( Name, " - (Windows|Microsoft) Internet Explorer" )
For wb in ComObjCreate( "Shell.Application" ).Windows
If ( wb.LocationName = Name ) && InStr( wb.FullName, "iexplore.exe" )
Return wb
}