#include <ie.au3>
#include <WinAPI.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Dim $inipath=@ScriptDir&"/peizhi.ini";检测用
Dim $inipath4=@ScriptDir&"/peizhi4.ini";检测用
Dim $inipath2=@ScriptDir&"/peizhi2.ini";排序用
Dim $inipath3=@ScriptDir&"/peizhi3.ini";检测类型用
Dim $show=0
Dim $mem=0
Dim $step=1
Dim $exit=0
Dim $url=""
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("表单控件跟踪测试", 361, 91, 283, 234)
$Input1 = GUICtrlCreateInput("http://tg1a146.mail.163.com/a/j/js3/main.jsp?sid=qCVFwVbbDFmCmtQnWHbbXBKQAgVkXzOb", 11, 23, 337, 21)
GUICtrlSetTip($Input1, "GOOD")
$Button1 = GUICtrlCreateButton("开始", 79, 49, 65, 33, 0)
$Button2 = GUICtrlCreateButton("退出", 215, 49, 65, 33, 0)
$Group1 = GUICtrlCreateGroup("输入要跟踪的IE地址:", 2, 4, 356, 84)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
AdlibRegister("OK123",50)
_IEErrorHandlerRegister()
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$oIE = _IECreate(GUICtrlRead($Input1), 0, 1, 1,0)
bdshuaxin()
$show=1;=1开启追踪
Case $Button2
; $oForm = _IEFormGetObjByName ($oIE, "register")
; $oText = _IEFormElementGetObjByName ($oForm, "username")
; MsgBox(0, "Form Element Value", _IEFormElementGetValue ($oText))
$exit=1
EndSwitch
WEnd
Func bdshuaxin();表单刷新
$oForms = _IEFormGetCollection($oIE)
$CONTER = @extended
; MsgBox(0, "表单信息", "这个页面上共有" & $CONTER & "个表单", 3)
TrayTip("提示","准备就绪,可以进行文本控件监控",6,1)
$file=FileOpen($inipath,2)
FileClose($file)
$file=FileOpen($inipath2,2)
FileClose($file)
$file=FileOpen($inipath3,2)
FileClose($file)
$file=FileOpen($inipath4,2)
FileClose($file)
IniWriteSection ( $inipath2, "步骤", "0="&_IEPropertyGet ($oIE, "locationurl"))
For $Form In $oForms
IniWriteSection ($inipath, $Form.name, "")
IniWriteSection ($inipath4, $Form.name, "")
IniWriteSection ($inipath3, $Form.name, "")
$oQuerys = _IEFormElementGetCollection($Form)
For $Query In $oQuerys
IniWrite($inipath,$Form.name,$Query.name,"")
IniWrite($inipath4,$Form.name,$Query.name,"")
IniWrite($inipath3,$Form.name,$Query.name,$Query.type)
Next
Next
$url=_IEPropertyGet ($oIE, "locationurl")
; MsgBox(0,"",$url)
EndFunc
Func OK123()
If $show=1 Then
biandanshuaxin2();是否增加表单监控
$var = IniReadSectionNames($inipath)
If @error Then
Else
If $var[0]>=1 Then;表单个数大于1
For $i=1 To $var[0]
$oForm = _IEFormGetObjByName ($oIE, $var[$i])
$var2 = IniReadSection($inipath, $var[$i]);获得表单名称为$var[$i]中的全部控件名称集合$var2
If @error Then
Else
For $j=1 To $var2[0][0];控件个数大于1
$oText = _IEFormElementGetObjByName ($oForm, $var2[$j][0])
$ml=_IEFormElementGetValue ($oText)
If $mem=0 Then IniWrite($inipath,$var[$i],$var2[$j][0],$ml)
If IniRead($inipath,$var[$i],$var2[$j][0],"")<>$ml Then;发现此时控件内容不等于预设内容
TrayTip("提示",$var2[$j][0]&"控件名被改变,目前值为:"&$ml,6,1)
IniWrite($inipath,$var[$i],$var2[$j][0],$ml);将值写入INI文件,不能为0
If ($ml<>0 Or IniRead($inipath,$var[$i],$var2[$j][0],"")="") Then IniWrite($inipath4,$var[$i],$var2[$j][0],$ml)
$var3 = IniReadSection($inipath2,"步骤") ;步骤中的全部变量集合$var3
If @error Then
Else
Local $sfy=0
For $z=1 To $var3[0][0]
;$s=StringRegExp($var3[$z][1], "\S+\s+\控件名称:+(.)", 3)
;MsgBox(0,"",$s)
If StringRight($var3[$z][1],StringLen($var3[$z][1])-StringInStr($var3[$z][1],":",0,-1))=$var2[$j][0] And StringMid($var3[$z][1],6,StringInStr($var3[$z][1],"控件名称:")-7)=$var[$i] Then $sfy=1
;MsgBox(0,$var3[0][0],$var3[$z][0])
Next
If $sfy=0 Then
;MsgBox(0,"","写入")
IniWrite($inipath2,"步骤",String($step),"表单名称:"&$var[$i]&" 控件名称:"&$var2[$j][0])
$step+=1
EndIf
EndIf
EndIf
Next
EndIf
Next
EndIf
EndIf
$mem=1
EndIf
If $exit=1 Then Exit
EndFunc
Func biandanshuaxin2();表单刷新2
;If $url<>_IEPropertyGet ($oIE, "locationurl")Then
;_IENavigate ($oIE, _IEPropertyGet ($oIE, "locationurl"))
; $oResult=_IEAttach ( _IEPropertyGet ($oIE, "locationurl"),"url")
; If IsObj($oResult) Then
; WinActivate(HWnd($oResult.HWND))
; SetError($_IEStatus_Success)
; SetExtended(1)
; $oIE=$oResult
; EndIf
;$oIE=_IECreate(_IEPropertyGet ($oIE, "locationurl"),1, 1, 0)
;_IEAttach ("The quick brown fox", "text")
$oIE=_IECreate(_IEAttach ($oIE, "text"),1, 1, 0)
; $url=_IEPropertyGet ($oIE, "locationurl")
;MsgBox(0,"",$url)
; EndIf
$oForms = _IEFormGetCollection($oIE)
$var = IniReadSectionNames($inipath)
If @error Then
Else
For $Form In $oForms;这是个循环,察看INI文件中是否包括本表单
Local $vpo=0
For $i=1 To $var[0]
If $Form.name=$var[$i] Then $vpo=1
Next
If $vpo=0 Then
IniWriteSection ($inipath, $Form.name, "")
IniWriteSection ($inipath4, $Form.name, "")
IniWriteSection ($inipath3, $Form.name, "")
$oQuerys = _IEFormElementGetCollection($Form)
For $Query In $oQuerys
IniWrite($inipath,$Form.name,$Query.name,"")
IniWrite($inipath4,$Form.name,$Query.name,"")
IniWrite($inipath3,$Form.name,$Query.name,$Query.type)
Next
EndIf
Next
EndIf
EndFunc