This program is made to automate the process of uploading multiple files to WXC. It has been tested on Windows 7 and XP.
#include <IE.au3>
Opt("WinTitleMatchMode",2) ;match substring of window
Opt("MustDeclareVars",1)
Func FileBrowserWindow($file,$memo)
_IENavigate($IE,"http://bbs.wenxuecity.com/legacy/upload")
Local $Obj = _IEDocGetObj($IE)
While _IEPropertyGet($IE, "busy") = True
Sleep(50); wait while IE is busy
WEnd
$IE.Document.All.Item("memo").Value=$memo
$IE.Document.All.Item("username").Value=$username
$IE.Document.All.Item("password").Value=$password
Local $postform = _IEFormGetObjByName($IE, "postform")
Local $music = _IEFormElementGetObjByName($postform, "music")
Local $title
If @OSVersion = "WIN_XP" Then
_IEAction($music, "focus")
ControlSend(_IEPropertyGet($IE, "hwnd"), "", "", $file)
Else
_IEAction($music, "focus")
Local $hIE = _IEPropertyGet($IE, "hwnd")
$title="Choose File to Upload"
ControlSend($hIE, "", "", " ")
WinWaitActive($title, "", 10);
ControlSetText($title, "", "[CLASS:Edit; INSTANCE:1]", $file)
ControlClick($title, "", "[CLASS:Button; INSTANCE:1]")
EndIf
$IE.Document.All.Item("fileupload").click
While isobj($IE.Document.All.Item("fileupload"))
Sleep(50)
WEnd
EndFunc
_IEErrorHandlerRegister("MyErrFunc")
Func MyErrFunc()
Local $ErrorScriptline = $oIEErrorHandler.scriptline
Local $ErrorNumber = $oIEErrorHandler.number
Local $ErrorNumberHex = Hex($oIEErrorHandler.number, 8)
Local $ErrorDescription = StringStripWS($oIEErrorHandler.description, 2)
Local $ErrorWinDescription = StringStripWS($oIEErrorHandler.WinDescription, 2)
Local $ErrorSource = $oIEErrorHandler.Source
Local $ErrorHelpFile = $oIEErrorHandler.HelpFile
Local $ErrorHelpContext = $oIEErrorHandler.HelpContext
Local $ErrorLastDllError = $oIEErrorHandler.LastDllError
Local $ErrorOutput = ""
$ErrorOutput &= "--> COM Error Encountered in " & @ScriptName & @CR
$ErrorOutput &= "----> $ErrorScriptline = " & $ErrorScriptline & @CR
$ErrorOutput &= "----> $ErrorNumberHex = " & $ErrorNumberHex & @CR
$ErrorOutput &= "----> $ErrorNumber = " & $ErrorNumber & @CR
$ErrorOutput &= "----> $ErrorWinDescription = " & $ErrorWinDescription & @CR
$ErrorOutput &= "----> $ErrorDescription = " & $ErrorDescription & @CR
$ErrorOutput &= "----> $ErrorSource = " & $ErrorSource & @CR
$ErrorOutput &= "----> $ErrorHelpFile = " & $ErrorHelpFile & @CR
$ErrorOutput &= "----> $ErrorHelpContext = " & $ErrorHelpContext & @CR
$ErrorOutput &= "----> $ErrorLastDllError = " & $ErrorLastDllError
MsgBox(0, "COM Error", $ErrorOutput)
SetError(1)
Return
EndFunc ;==>MyErrFunc
If $CmdLine[0] <> 1 Then
MsgBox(0, "Usage", "autoit3 script.txt playlist.txt")
Exit
EndIf
Local $file = FileOpen($CmdLine[1], 128)
If $file = -1 Then
MsgBox(0, "Error", "Unable to open playlist file : "&$CmdLine[1])
Exit
EndIf
Local $username, $password
Local $IE = _IECreate()
$IE.Visible = 1
While 1
Local $line = FileReadLine($file)
If @error = -1 Then ExitLoop
Local $array
$array = StringRegExp($line,"^\s*password\s*=\s*(\S*)", 1)
If UBound($array) = 1 Then
$password=$array[0]
EndIf
$array = StringRegExp($line,"^\s*username\s*=\s*(\S*)", 1)
If UBound($array) = 1 Then
$username=$array[0]
EndIf
$array = StringRegExp($line,"^\s*(.+?)\s*[|]\s*(.*)", 1)
If UBound($array) = 2 Then
If FileExists($array[0]) Then
FileBrowserWindow($array[0],$array[1])
Else
MsgBox(4096, "This file does not exist : ", $array[0])
EndIf
EndIf
WEnd
FileClose($file)