#include <Excel.au3>
#include <Array.au3>
#include <File.au3>
#include <IE.au3>
_main()
Exit
Func _main()
_xunhuan()
EndFunc
Func _bofang()
;获取配置文件中序号对应的课程信息,并写入数组
Local $Dir1 = StringLeft(@AutoItExe,StringInStr(@AutoItExe,"",0,-1)) ;程序所在目录
;MsgBox(64,"",$dir1) ;测试目录是否正确
Local $oExcel = _ExcelBookOpen($Dir1&"学习课程列表.xls")
Local $Num = IniRead($Dir1&"配置.ini","setting","n",1) ;读取配置文档
Local $aArray = _ExcelReadArray($oExcel, $Num + 1, 1, 4) ;方向是垂直的
;_ArrayDisplay($aArray, "Horizontal") ;测试数组内容
If IniRead($Dir1&"配置.ini", "setting","m","1") = "" Then
For $i = 1 To 100 ;循环
$sCellValue = _ExcelReadCell($oExcel, $i+1, 1)
If IsNumber($sCellValue) = 0 Then
ExitLoop
EndIf
Next
Local $Max_Num = _ExcelReadCell($oExcel, $i, 1)
$pz = IniWrite($Dir1&"配置.ini", "setting","m",$Max_Num)
EndIf
$pz = IniWrite($Dir1&"配置.ini", "setting","n",$Num+1)
Local $x = IniRead($Dir1&"配置.ini","mouse","x",1) ;读取配置文档
Local $y = IniRead($Dir1&"配置.ini","mouse","y",1) ;读取配置文档
_ExcelBookClose($oExcel)
;再重新打开默认浏览器,原浏览器窗口保持网站登陆状态
Local $var = RegRead("HKEY_CLASSES_ROOT\http\shell\open\command", "") ;读取默认浏览器建值
Local $result = StringInStr($var, ".exe") ;获取字符串中.exe所在位置
Local $dir2 = StringMid($var, 2, $result + 2) ;截取字符串,获取默认浏览器路径
;MsgBox(4096, "Program files are in:", $dir) ;检查默认浏览器路径是否正确
ShellExecuteWait($dir2,"","","",@SW_MAXIMIZE) ;最大化打开浏览器,不加载指定网站,最大化不好使
;打开指定课程,等待加载完毕
Local $oIE = _IECreate("about:blank", 1,1,1,0)
WinActivate("about:blank","") ;激活窗口
WinSetState("about:blank","",@SW_MAXIMIZE) ;将激活窗口最大化,解决上面最大化失败问题
_IENavigate($oIE, $aArray[3]) ;直接在一个存在的浏览器窗口打开指定课程,等待加载完毕
sleep(1000) ;延时1秒钟
;MouseClick("left",950,480) ;占击开始学习,位置信息可升级编写脚本
WinActivate($aArray[1],"") ;激活窗口
MouseClick("left",$x,$y) ;占击开始学习,位置信息可升级编写脚本
;程序暂停运行时间为课程时长加1分钟,之后关闭此浏览器窗口
;Sleep(60000*($aArray[2]+1)) ;延时分钟数加1
For $i = $aArray[2]+1 To 0 Step -1
If $i = 0 Then
Sleep(1000)
;MsgBox(4096, "窗口名称",$aArray[1],10)
WinClose ($aArray[1])
Else
TrayTip("倒计时","剩余"&$i&"分钟",10,1)
Sleep(60000)
EndIf
Next
EndFunc ;==>_bofang
Func _xunhuan()
Local $Dir1 = StringLeft(@AutoItExe,StringInStr(@AutoItExe,"",0,-1)) ;程序所在目录
Local $m = IniRead($Dir1&"配置.ini","setting","m",1) ;读取配置文档
Local $n = IniRead($Dir1&"配置.ini","setting","n",1)
Local $i = $n
While $i <= $m
$i = $i + 1
_bofang()
WEnd
EndFunc ;==>_xunhuan