试修改如下:
$file = FileOpen("result.txt", 2) ;==> 这一句前面要加个变量
If $file = -1 Then
MsgBox(4096, "错误", "不能打开文件.")
Exit
EndIf
Dim $username[5] = ["111a2fe", "sw136", "a23eeeeeeeeee", "a233", "a134rt"]
Dim $password[5] = ["123567", "333aaae", "aaaaaaa", "dkdkdkdk", "dddddddd"]
Run("register.exe")
WinWaitActive("用户注册")
For $i = 0 To 4
$a = 0 ;==> 这句可以不要
ControlSend("用户注册", "", 5, $username[$i]) ;==> 注意控件ID是否正确
;GUICtrlSetData(5,$username[$i])
ControlSend("用户注册", "", 7, $password[$i]) ;==> 注意控件ID
;GUICtrlSetData(7,$password[$i])
ControlClick("用户注册", "", 8)
$a = WinGetState("错误信息")
ControlClick("错误信息", "", 2) ;==> 这一句貌似不应该写在这,据猜测,可能是注册失败才有这个窗口出现
;MsgBox(0,"aa",$a)
If $a <> 0 Then
WinWaitActive("错误信息")
ControlClick("错误信息", "", 2)
FileWrite($file, "用户名: " & $username[$i] & @CRLF & "密码:" & $password[$i] & @CRLF & "right" & @CRLF) ;==> 修改
;MsgBox(0,"bb",$a)
Else
WinWaitActive("注册成功")
ControlClick("注册成功", "", 2)
;MsgBox(0,"cc",$a)
EndIf
Next