该段代码从setting.ini文件中读取QQ号和密码,然后自动进行登录和退出并进行记录,适用于QQ2009版本
setting.ini文件格式如下:
[lianzhong]
lianzhong1No=lianzhong1Pwd
lianzhong2No=lianzhong2Pwd
lianzhong3No=lianzhong3Pwd
AutoIt代码如下:
#include <Date.au3> #include <IE.au3> Global $INIFile,$Values $INIFile = "setting.ini" $Values = IniReadSection($INIFile, "LianZhong") $MK_Count = $Values[0][0] $outFileName = "log.xml" $outfile = FileOpen($outFileName, 2) FileWriteLine($outfile, '<?xml version="1.0" encoding="GB2312"?>') FileWriteLine($outfile, '<test>') For $Index = 1 To $MK_Count Run("C:/Program Files/GlobalLink/Game/Share/glworld.exe") WinWait("登录信息","联众") WinActivate("登录信息","联众") For $I = 1 To 99 ControlSend("登录信息","","[CLASS:AfxWnd42; INSTANCE:1]","{backspace}") Next ControlSend("登录信息","","[CLASS:AfxWnd42; INSTANCE:1]",$Values[$Index][0]) Sleep(2000) ;Opt("SendKeyDelay", 50) ;Opt("SendKeyDownDelay",50) ControlSend("登录信息","","[CLASS:AfxWnd42; INSTANCE:1]","{tab}") ;ControlSend("登录信息","","","qazwsxedc") ;这里用ControlSend登录出错 Send($Values[$Index][1]); Send("{enter}"); FileWrite($outfile, '<item type="LianZhong" time="'& _Now() &'" code="' & $Values[$Index][0] &'" ') ;ControlSend("登录信息","","[CLASS:Edit; INSTANCE:1]","qazwsxedc") ;MsgBox(64, "通知-by liyi", "等待25秒钟以保证登陆成功", 25) if WinWait("游戏NPC","",100) Then FileWriteLine($outfile, 'success="true"/>') MsgBox(64, "通知-by liyi", "5秒钟后关闭【游戏NPC】窗口", 5) WinClose("游戏NPC") MsgBox(64, "通知-by liyi", "5秒钟后退出游戏", 5) Opt("WinTitleMatchMode",2) WinClose($Values[$Index][0]) Opt("WinTitleMatchMode",1) WinWait("关闭窗口","",5) MsgBox(64, "通知-by liyi", "5秒钟后点击【退出大厅】按钮", 5) ControlClick("关闭窗口","","[CLASS:Button; INSTANCE:2]") Else FileWriteLine($outfile, 'success="false"/>') WinClose("glworld","错误"); WinClose("登录信息","联众"); EndIf Sleep(2000) ProcessClose ("glworld.exe") Sleep(2000) Next FileWriteLine($outfile, '</test>') FileClose($outfile)