autoit无法在Web浏览器上阅读文本

时间:2017-05-26 23:34:12

标签: window controls autoit

当我在IE和Chrome中打开浏览器并尝试识别控件时,我只能看到窗口=' Chrome_widgetwin_1'和控制='中间D3D窗口'在铬。在IE中,我只能看到window =' IEFrame'和控制=' internet explorer_server'。将鼠标悬停在包括链接和按钮在内的任何其他内容上仍然只显示这些(即使鼠标坐标发生变化)。我也似乎无法查看隐藏或可见的页面上的任何重要文本。我试图获取不同控件和文本字符串的坐标,但不能。

当我将浏览器打开为活动页面时,我尝试了以下内容来查看页面上的控件:

#include <Array.au3>
#include <WinAPI.au3>
ConsoleWrite("Make your window active!" & @CRLF)
Sleep(5000)
GetAllWindowsControls(WinGetHandle("[ACTIVE]"))
Func GetAllWindowsControls($hCallersWindow, $bOnlyVisible=Default, $sStringIncludes=Default, $sClass=Default)
; Get all list of controls
If $bOnlyVisible = Default Then $bOnlyVisible = False
If $sStringIncludes = Default Then $sStringIncludes = ""
If $sClass = Default Then $sClass = ""
$sClassList = WinGetClassList($hCallersWindow)
; Create array
$aClassList = StringSplit($sClassList, @CRLF, 2)
; Sort array
_ArraySort($aClassList)
_ArrayDelete($aClassList, 0)
; Loop
$iCurrentClass = ""
$iCurrentCount = 1
$iTotalCounter = 1
If StringLen($sClass)>0 Then
For $i = UBound($aClassList)-1 To 0 Step - 1
If $aClassList[$i]<>$sClass Then
_ArrayDelete($aClassList,$i)
EndIf
Next
EndIf
For $i = 0 To UBound($aClassList) - 1
If $aClassList[$i] = $iCurrentClass Then
$iCurrentCount += 1
Else
$iCurrentClass = $aClassList[$i]
$iCurrentCount = 1
EndIf
$hControl = ControlGetHandle($hCallersWindow, "", "[CLASSNN:" & $iCurrentClass & $iCurrentCount & "]")
$text = StringRegExpReplace(ControlGetText($hCallersWindow, "", $hControl), "[\n\r]", "{@CRLF}")
$aPos = ControlGetPos($hCallersWindow, "", $hControl)
$sControlID = _WinAPI_GetDlgCtrlID($hControl)
$bIsVisible = ControlCommand($hCallersWindow, "", $hControl, "IsVisible")
If $bOnlyVisible And Not $bIsVisible Then
$iTotalCounter += 1
ContinueLoop
EndIf
If StringLen($sStringIncludes) > 0 Then
If Not StringInStr($text, $sStringIncludes) Then
$iTotalCounter += 1
ContinueLoop
EndIf
EndIf
If IsArray($aPos) Then
MsgBox(0,"","Func=[GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[" & StringFormat("%4s", $aPos[0]) & "] YPos=[" & StringFormat("%4s", $aPos[1]) & "] Width=[" & StringFormat("%4s", $aPos[2]) & "] Height=[" & StringFormat("%4s", $aPos[3]) & "] IsVisible=[" & $bIsVisible & "] Text=[" & $text & "]." & @CRLF)
Else
MsgBox(0,"","Func=[GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[winclosed] YPos=[winclosed] Width=[winclosed] Height=[winclosed] Text=[" & $text & "]." & @CRLF)
EndIf
If Not WinExists($hCallersWindow) Then ExitLoop
$iTotalCounter += 1
Next
EndFunc   ;==>GetAllWindowsControls

当我运行它时,我得到此输出,表明它没有在浏览器中看到任何控件:enter image description here

0 个答案:

没有答案