主脚本如下:#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <File.au3>
$gc_url = "http://disk.nbfas.cn/test.htm" ;上传地址
$gc_Formtitle = "上传" ;窗体标题
If WinExists($gc_Formtitle, "") Then Exit ;查看是否窗体是否存在
$Form1 = GUICreate($gc_Formtitle, 334, 283, 193, 125, -1, $WS_EX_ACCEPTFILES)
$Label1 = GUICtrlCreateLabel("选择文件夹...", 40, 40, 73, 17)
$inputDir = GUICtrlCreateInput("", 40, 72, 177, 21)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
$btnBrowse = GUICtrlCreateButton("浏览...", 240, 72, 75, 25, 0)
$btnUpload = GUICtrlCreateButton("上传", 40, 120, 75, 25, 0)
$editDisplay = GUICtrlCreateEdit("", 48, 168, 185, 89, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN))
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $btnBrowse ;浏览文件夹
$dir = FileSelectFolder("请选择文件夹:", "")
If Not @error Then GUICtrlSetData($inputDir, $dir)
Case $btnUpload ;上传
Upload()
EndSwitch
WEnd
Func Upload()
$dir = GUICtrlRead($inputDir) ;读取文件夹
If FileExists($dir) = 0 Then ;<== 检查文件夹是否有错
MsgBox(0, "出错", "请检查文件夹是否正确")
GUICtrlSetState($inputDir, $GUI_FOCUS)
Else ;无错=将选定文件夹内所有文件读入数组
$aFileList = _FileListToArray($dir, "*", 1)
;<== 检查是否有文件
If @error = 4 Then ;没有文件
MsgBox(0, "", "没有发现文件")
;Exit
Else ;有文件
For $iFile = 1 To $aFileList[0] ; 循环执行每一个文件
$sFilePath = $dir & "" & $aFileList[$iFile]
Run('a.exe "' & $sFilePath & '"')
$oIE = _IECreate($gc_url, 0, 1)
$o_form = _IEFormGetObjByName($oIE, "upload_form")
$o_browse = _IEFormElementGetObjByName($o_form, "file")
;$hwnd_ie = _IEPropertyGet($oIE, "hwnd")
_IEAction($o_browse, "click") ;单击“浏览”
;此时已由a.exe搞定其它事务~
;_IELoadWait ($oIE)
;_IEAction($o_login, "click")
MsgBox(0, 0, $sFilePath & ' 已搞定')
Next ;<== 循环结束
EndIf ;<== 检查是否有文件
EndIf ;<== 检查文件夹是否有错
EndFunc ;==>Upload
以下这个是辅助脚本,编译为"a.exe"后和主脚本放在一起。If $CmdLine[0] = 1 Then
AdlibRegister('sr')
$a = 1
While $a = 1
Sleep(50)
WEnd
EndIf
Func sr()
If WinActive("选择文件") Then
ControlSetText("选择文件", "文件名", "Edit1", $CmdLine[1])
ControlClick("选择文件", "文件名", "Button2")
$a = 0
EndIf
EndFunc ;==>sr
|