本帖最后由 zhaicheng 于 2011-2-23 10:36 编辑
控件不是标准控件,郁闷
#include <WinAPI.au3>
#include <GuiButton.au3>
#include <Array.au3>
#include "CoProc.au3"
#include <File.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
$h_gui = GUICreate("Dream mail账号批量导入 ", 633, 447, 192, 124)
$userFilename = "user.txt"
$PassFilename = "pass.txt"
$Button1 = GUICtrlCreateButton(" 开始导入", 400, 384, 121, 41, $WS_GROUP)
$EditUser = GUICtrlCreateEdit("", 40, 64, 241, 273)
$EditPass = GUICtrlCreateEdit("", 336, 64, 241, 273)
$Label1 = GUICtrlCreateLabel("账号", 112, 24, 44, 17)
$Label2 = GUICtrlCreateLabel("密码", 448, 24, 28, 17)
$Label3 = GUICtrlCreateLabel("首先打开dream mail,然后点击开始导入", 32, 400, 292, 20)
GUICtrlSetFont(-1, 12, 400, 2, "宋体")
_CoProc("_AutoCloseDialogue", $h_gui)
$_TxtTitle = "DreamMail "
GUICtrlSetColor(-1, 0x0000FF)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
_read()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
_save()
Run("kill.bat")
Exit
Case $Button1
_Start()
EndSwitch
WEnd
Func _read()
$tmp = FileRead($userFilename)
GUICtrlSetData($EditUser, $tmp)
$tmp = FileRead($PassFilename)
GUICtrlSetData($EditPass, $tmp)
EndFunc ;==>_read
Func _save()
_FileCreate($userFilename)
FileWrite($userFilename, GUICtrlRead($EditUser))
_FileCreate($PassFilename)
FileWrite($PassFilename, GUICtrlRead($EditPass))
EndFunc ;==>_save
Func _Start()
$User_arr = StringSplit(GUICtrlRead($EditUser), @CRLF, 1)
$Pass_arr = StringSplit(GUICtrlRead($EditPass), @CRLF, 1)
If $User_arr[0] <> $Pass_arr[0] Then
MsgBox(262144, "账号和密码数量不等", "请检查")
Return
EndIf
$Count = $User_arr[0]
For $i = $Count To 1 Step -1
If StringLen(StringStripWS($User_arr[$i], 8)) = 0 Then
_ArrayDelete($User_arr, $i)
$User_arr[0] = $User_arr[0] - 1
EndIf
Next
$Count = $Pass_arr[0]
For $i = $Count To 1 Step -1
If StringLen(StringStripWS($Pass_arr[$i], 8)) = 0 Then
_ArrayDelete($Pass_arr, $i)
$Pass_arr[0] = $Pass_arr[0] - 1
EndIf
Next
WinWait($_TxtTitle)
$HwndP = WinGetHandle($_TxtTitle)
WinActivate($HwndP)
For $i = 1 To $User_arr[0]
$user = $User_arr[$i]
$pass = $Pass_arr[$i]
$w_new = WinWait("[Class:TAccountManageForm]", "", 1);("邮件帐号")
If Not IsHWnd($w_new) Then
$H_con = ControlGetHandle($HwndP, "", "[CLASS:TTBXToolbar; INSTANCE:1]")
ControlSend("", "", $H_con, "^{F12}")
EndIf
$w_new = WinWait("[Class:TAccountManageForm]");("邮件帐号")
WinActivate($w_new)
WinWaitActive($w_new)
WinWaitActive($w_new)
$btn_New = ControlGetHandle($w_new, "", "[CLASS:TcxTreeList; INSTANCE:1]")
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $btn_New = ' & $btn_New & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
ControlSend($w_new, "", $btn_New, "!n")
$w_add = WinWait("[Class:TAccountNewForm]")
WinActivate($w_add)
WinWaitActive($w_add, "", 1)
ControlSetText($w_add, "", "[CLASS:TEdit; INSTANCE:3]", $user)
ControlSetText($w_add, "", "[CLASS:TEdit; INSTANCE:2]", $pass)
ControlSetText($w_add, "", "[CLASS:TEdit; INSTANCE:1]", $user)
$panel = ControlGetHandle($w_add, "", "[CLASS:TPanel; INSTANCE:13]")
ControlSend($w_add, "", $panel, "!f")
Sleep(1000)
Next
MsgBox(262144, "导入完成!", "共导入" & $i & "条记录" & @CRLF & "对话框1秒后自动关闭。。。", 1)
EndFunc ;==>_Start
Func _AutoCloseDialogue($h_gui)
Do
$confirmWindow = WinWait("选择", "您确定要重新添加一个吗?")
_GUICtrlButton_Click(ControlGetHandle($confirmWindow, "", "[CLASS:Button; INSTANCE:1]"))
Until 1 = 2
EndFunc ;==>_AutoCloseDialogue
|