This program is made to automate the process of uploading multiple files to WXC. It has been tested on Windows 7 and XP.
Installation.
- Download Autoit v3 and install it, and note down the installation path (the default path is C:\Program Files\AutoIt3) which will be used below
- Create a directory, like C:\upload.
- Copy this code and paste it into an editor like NOTEPAD:
- Save the file in the directory (C:\upload) created above, naming it script.txt, making sure you choose encoding as "UNICODE".
- Start Windows Explorer, browse to the directory C:\upload, right click on the blank area in the right panel, then New⇒Shortcut
Type "C:\Program Files\AutoIt3\AutoIt3.exe", then Next
Type "upload" (without quotes), then Finish - Right-click shortcut "upload" just created and choose Properties
Change "Target" to :
"C:\Program Files\AutoIt3\AutoIt3.exe" script.txt playlist.txt
Change "Start in" to :
C:\upload - In C:\upload, create a sub-folder named "mp3" (without quotes) which will contain mp3 files to be uploaded.
#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)
Usage.
- Start NOTEPAD and then type in following lines
username=poiuyt
password=secret
C:\upload\mp3\1.mp3 | 第一首歌名
C:\upload\mp3\2.mp3 | 第二首歌名
C:\upload\mp3\3.xml | Playlist
...
username/password are those one uses to log on Wenxuecity.
Each song line is composed of the path to the mp3 file and song name separated by a pipe |. Other types of files (like .xml) can be uploaded as demonstrated by the third line.
Save the content to a file called "playlist.txt"(without quotes, in C:\upload), by MAKING SURE you choose encoding as "UNICODE". - Double click shortcut "upload", which will start uploading all the mp3 in playlist.txt.