找回密码
 加入
搜索
查看: 4613|回复: 2

[IE类操作] 子脚本使用非数组变量

[复制链接]
发表于 2010-3-1 19:14:30 | 显示全部楼层 |阅读模式
论坛里qq自动注册的代码,
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
Local $Config_File= "Config.INI"
Local $Adsl_Name = IniRead($Config_File,"System","宽带名称","")
Local $Adsl_User = IniRead($Config_File,"System","宽带用户","")
Local $Adsl_Pass = IniRead($Config_File,"System","宽带密码","")
Local $Date = @MON&"-"&@MDAY
Local $Reg_Pass = IniRead($Config_File,"System","注册密码","")
$Form_QQ_Reg = GUICreate("QQ号码注册机 ", 438, 388)
$Tab1 = GUICtrlCreateTab(8, 9, 422, 370)
GUICtrlSetFont(-1, 9, 800, 0, "宋体")
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$TabSheet1 = GUICtrlCreateTabItem("资料设置")
GUICtrlCreateGroup("", 16, 34, 274, 196)
GUICtrlCreateLabel("帐号:", 29, 50, 46, 17)
GUICtrlSetFont(-1, 10, 800, 0, "宋体")
GUICtrlSetColor(-1, 0x800000)
GUICtrlCreateLabel("昵称:", 29, 80, 46, 17)
GUICtrlSetFont(-1, 10, 800, 0, "宋体")
GUICtrlSetColor(-1, 0x800000)
GUICtrlCreateLabel("生日:", 29, 110, 46, 17)
GUICtrlSetFont(-1, 10, 800, 0, "宋体")
GUICtrlSetColor(-1, 0x800000)
GUICtrlCreateLabel("性别:", 29, 141, 46, 17)
GUICtrlSetFont(-1, 10, 800, 0, "宋体")
GUICtrlSetColor(-1, 0x800000)
GUICtrlCreateLabel("密码:", 29, 171, 46, 17)
GUICtrlSetFont(-1, 10, 800, 0, "宋体")
GUICtrlSetColor(-1, 0x800000)
GUICtrlCreateLabel("省份:", 29, 201, 46, 17)
GUICtrlSetFont(-1, 10, 800, 0, "宋体")
GUICtrlSetColor(-1, 0x800000)
$Input_Reg_User = GUICtrlCreateInput("", 75, 47, 113, 21)
$Input_Reg_Nickname = GUICtrlCreateInput("", 75, 76, 201, 21)
$Combo_Y = GUICtrlCreateCombo("2009", 75, 106, 57, 25)
$Combo_M = GUICtrlCreateCombo("12", 156, 106, 41, 25)
$Combo_D = GUICtrlCreateCombo("30", 220, 106, 41, 25)
$Radio_Sex1 = GUICtrlCreateRadio("男", 76, 138, 41, 17)
$Radio_Sex2 = GUICtrlCreateRadio("女", 129, 138, 41, 17)
GUICtrlCreateLabel("年", 137, 110, 16, 17)
GUICtrlCreateLabel("月", 203, 109, 16, 17)
GUICtrlCreateLabel("日", 266, 109, 16, 17)
$Combo_Province = GUICtrlCreateCombo("", 75, 199, 113, 25)
GUICtrlSetData(-1,_Get_Province(),"随机选择")
GUICtrlCreateLabel("@QQ.COM", 193, 50, 78, 20)
GUICtrlSetFont(-1, 12, 400, 0, "宋体")
GUICtrlSetColor(-1, 0x800000)
$Input_Reg_Pass = GUICtrlCreateInput($Reg_Pass, 75, 167, 113, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("", 295, 34, 128, 196)
GUICtrlCreateLabel("宽带名称:", 304, 48, 64, 17)
$Input_Adsl_Name = GUICtrlCreateInput($Adsl_Name, 303, 64, 112, 21)
GUICtrlCreateLabel("宽带账号:", 303, 91, 64, 15)
$Input_Adsl_User = GUICtrlCreateInput($Adsl_User, 303, 107, 112, 21)
GUICtrlCreateLabel("宽带密码:", 304, 134, 64, 17)
$Input_Adsl_Pass = GUICtrlCreateInput($Adsl_Pass, 303, 150, 112, 21)
GUICtrlCreateLabel("注册次数:", 304, 180, 64, 17)
$Combo_Reg_n = GUICtrlCreateCombo("5", 370, 177, 44, 25)
$Button_Adsl = GUICtrlCreateButton("拨号", 375, 203, 41, 21, $WS_GROUP)
;~ $Checkbox_Adsl = GUICtrlCreateCheckbox("自动拨号", 303, 205, 65, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("", 16, 229, 407, 142)
$Pic_Code = GUICtrlCreatePic("getimage.jpg", 20, 320, 120, 48)
GUICtrlSetCursor (-1, 0)
$Input_Code = GUICtrlCreateInput("", 145, 330, 60, 30)
GUICtrlSetFont(-1, 16, 400, 0, "黑体")
GUICtrlSetColor(-1, 0xFF0000)
$Button_Start = GUICtrlCreateButton("提交注册", 325, 336, 89, 25, $WS_GROUP)
$Edit_Reg_Log = GUICtrlCreateEdit("", 21, 240, 395, 81, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN))
GUICtrlSetFont(-1, 9, 400, 0, "宋体")
GUICtrlSetColor(-1, 0x008000)
;~ $Checkbox1 = GUICtrlCreateCheckbox("免回车", 222, 341, 57, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$TabSheet2 = GUICtrlCreateTabItem("网页界面")
$oIE = _IECreateEmbedded ()
GUICtrlCreateObj($oIE,15, 37, 408, 331)
$TabSheet3 = GUICtrlCreateTabItem("软件说明")
$Edit2 = GUICtrlCreateEdit("", 15, 37, 408, 331, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN))
GUICtrlSetData(-1, "")
GUICtrlCreateTabItem("")
_Go()
GUISetState(@SW_SHOW)


While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
        Case $Button_Start
                        _Form()
                Case $Button_Adsl
                        _Adsl()
                Case $GUI_EVENT_PRIMARYDOWN
                         $Pos = GUIGetCursorInfo()
                            If $Pos <> 0 then 
                    If ($Pos[4] == $Pic_Code) Then 
                                            _Go();刷新验证码        
                                                _Countdown("10")
                    EndIf                                                
                                EndIf                
        EndSwitch
WEnd

Func _Go();加载网页
;~         GUICtrlSetData($Edit_Reg_Log,"加载网页:http://emailreg.qq.com/cgi-bin/signup/step1?regtype=0"&@CRLF,1)
        _IENavigate ($oIE, "http://emailreg.qq.com/cgi-bin/signup/step1?regtype=0")
        _Get_Code()
EndFunc

Func _Get_Code()
GUICtrlSetData($Input_Code,"")
GUICtrlSetState ($Input_Code,$GUI_FOCUS)
$sCheckCodeImgFile = ""
Do
        $sCheckCodeImgFile = myGetImgPath($oIE,1)
        Sleep(100)
Until $sCheckCodeImgFile<>""
GUICtrlSetImage ($Pic_Code,$sCheckCodeImgFile)
EndFunc

Func _Form()
$Code = GUICtrlRead($Input_Code)
$Reg_User = _ran_dom(1,5)&_ran_dom(0,5)
GUICtrlSetData($Input_Reg_User,$Reg_User)
$Reg_Nickname = $Reg_User
GUICtrlSetData($Input_Reg_Nickname,$Reg_Nickname)
$Reg_Y = Random(1950,2008,1)
GUICtrlSetData($Combo_Y,$Reg_Y)
$Reg_M = Random(1,12,1)
GUICtrlSetData($Combo_M,$Reg_M)
$Reg_D = Random(1,28,1)
GUICtrlSetData($Combo_D,$Reg_D)
$Reg_Pass = GUICtrlRead($Input_Reg_Pass)
$Province = GUICtrlRead($Combo_Province)
If $Province = "随机选择" Then
        $s = Random(1,34,1)
        $var = IniReadSection("Config.ini", "Province")
    For $i = 1 To $var[0][0]
        If $i = $s Then
                        $Province_ID = $var[$i][1]
                    ExitLoop
                EndIf
        Next 
Else
        $Province_ID = IniRead("Config.ini","Province",$Province,"11")
EndIf
GUICtrlSetData($Input_Reg_Pass,$Reg_Pass)
$oForm = _IEFormGetObjByName($oIE,"regForm");获取“regForm”表单对象
$oQuerys = _IEFormElementGetCollection($oForm);返回“regForm”表单元素的对象变量合集
$n = 1
For $Query In $oQuerys
If $n = 3 Then _IEFormElementSetValue ($Query,$Reg_User);账号
If $n = 4 Then _IEFormElementSetValue ($Query,"1");邮箱后缀 1=@QQ.com  3=@foxmail.com
If $n = 6 Then _IEFormElementSetValue ($Query,$Reg_Nickname);昵称
If $n = 7 Then _IEFormElementSetValue ($Query,$Reg_Y);年
If $n = 8 Then _IEFormElementSetValue ($Query,$Reg_M);月
If $n = 9 Then _IEFormElementSetValue ($Query,$Reg_D);日
If $n = 12 Then _IEFormElementSetValue ($Query,$Reg_Pass);密码
If $n = 13 Then _IEFormElementSetValue ($Query,$Reg_Pass);确认密码
If $n = 14 Then _IEFormElementSetValue ($Query,"1");国家
If $n = 15 Then _IEFormElementSetValue ($Query,$Province_ID);省份
;~ If $n = 16 Then _IEFormElementSetValue ($Query,"22");市
If $n = 17 Then _IEFormElementSetValue ($Query,$Code);验证码
$n = $n +1
Next
_IEFormElementRadioSelect ($oForm, "2", "gender", 1, "byValue");性别
_IELinkClickByText($oIE, "确定并同意以下条款");提交
Sleep(2000)
$Log_txt = _IEBodyReadText($oIE)

Select
    Case _Search($Log_txt,"恭喜(.*?)成功") <> ""
         $QQ = _Search($Log_txt,'与您的Email帐号对应的QQ号码为(.*?),')
                 $Email = _Search($Log_txt,'您当前的主显帐号是:(.*?)什么是主显帐号')
                 FileWrite("成功注册QQ.txt",$QQ&" -- "&$Reg_Pass&" -- "&$Email&@CRLF)
                 IniWrite("QQ号码.ini","QQ号码",$QQ,"0")
                 GUICtrlSetData($Edit_Reg_Log,"注册成功:"&$QQ&" -- "&$Reg_Pass&" -- "&$Email&@CRLF,1)
        Case _Search($Log_txt,"此IP申请(.*?)过于频繁") <> ""
                 GUICtrlSetData($Edit_Reg_Log,"注册失败:此IP申请过于频繁,请更换IP!!!"&@CRLF,1)
;~                  _Adsl()
        Case _Search($Log_txt,"非(.*?)问") <> ""
                 GUICtrlSetData($Edit_Reg_Log,"注册失败:非法访问!!!(请注意注册间隔时间,保持在5-10秒)"&@CRLF,1)        
        Case Else
                 GUICtrlSetData($Edit_Reg_Log,"注册失败:注册资料错误或者验证码错误!!!"&@CRLF,1)         
EndSelect
 _Go()
 _Countdown("10");提交延迟 参数 10S
EndFunc

Func _Search($Txt,$Condition);表达式函数
        Local $Result
        $array = StringRegExp($Txt,$Condition, 2, 1)
        for $i = 0 to UBound($array) - 1
            $Result = $array[$i]
                Next
        Return $Result
EndFunc

Func _Get_Province()
$Province_z = "随机选择"
$var = IniReadSection("Config.ini", "Province")
For $i = 1 To $var[0][0]
$Province_z = $Province_z&"|"&$var[$i][0]
Next 
Return $Province_z
EndFunc

Func _Ran_dom($var,$n)
        $cdk = ""
        if $var = 1 then 
             FOR $i= 1 to $n
              $cdk = $cdk&Chr(Random(Asc("a"), Asc("z")))
             Next
         Else
             FOR $i= 1 to $n
              $cdk = $cdk&Chr(Random(Asc("1"), Asc("9")))
            Next
        EndIf 
        Return $cdk
EndFunc

;~ Func _Adsl()
;~ Do
;~ While 1
;~ RunWait(@ComSpec & " /c rasdial "&$Adsl_Name&"  /DISCONNECT ","",@SW_HIDE)
;~ RunWait(@ComSpec & " /c rasdial "&$Adsl_Name&" "&$Adsl_User &" "&$Adsl_Pass,"",@SW_HIDE)
;~ $x = DLLCall("sensapi.dll","int","IsNetworkAlive","str",$Adsl_Name)
;~      If $x[0] <> 0 Then 
;~                 $IP = @IPAddress2
;~         ExitLoop
;~      EndIf
;~ WEnd
;~ Until _Ip_Detection($Date,$IP) = "0"
;~ EndFunc

Func _Adsl()
GUICtrlSetData($Edit_Reg_Log,"正在拨号,请稍候..."&@CRLF,1)        
While 1
RunWait(@ComSpec & " /c rasdial "&$Adsl_Name&"  /DISCONNECT ","",@SW_HIDE)
RunWait(@ComSpec & " /c rasdial "&$Adsl_Name&" "&$Adsl_User &" "&$Adsl_Pass,"",@SW_HIDE)
$x = DLLCall("sensapi.dll","int","IsNetworkAlive","str",$Adsl_Name)
     If $x[0] <> 0 Then 
        ExitLoop
     EndIf
 WEnd
 GUICtrlSetData($Edit_Reg_Log,"拨号完成..."&@CRLF,1)        
EndFunc

Func _Countdown($var);倒计时
GUICtrlSetState($Button_Start,$GUI_DISABLE)
For $i = $var to 1 Step -1 
Sleep(1000)
GUICtrlSetData($Button_Start,"倒计时:"&$i-1&" 秒")
Next
GUICtrlSetData($Button_Start,"提交注册")
GUICtrlSetState($Button_Start,$GUI_ENABLE)        
EndFunc

Func _Ip_Detection($Date,$IP)
        $n_ip = IniRead($Config_File,$Date,$Ip,"0")
        If $n_ip = "0" Then IniWrite($Config_File,$Date,$Ip,"1")
        Return $n_ip
EndFunc

Func myGetImgPath($func_oIE, $func_index=0)
        Local $oImg = _IEImgGetCollection ($func_oIE, $func_index)
        If @error Then Return ""
        Local $oPic = $func_oIE.Document.Body.CreateControlRange()
        $oPic.Add($oImg)
        $oPic.Select()
        $oPic.ExecCommand("Copy");复制到剪贴板
        Return ClipGet()
EndFunc
一运行就出现  子脚本使用非数组变量 ??
发表于 2010-3-1 20:18:33 | 显示全部楼层
先做配置文件再运行。
 楼主| 发表于 2010-3-1 20:41:01 | 显示全部楼层
谢谢,原来是没配置文件啊....
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-17 00:19 , Processed in 0.074910 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表