Вот основной URL Основной HTML-документ URL-адрес кнопки, которую я пытаюсь найти Второй HTML-документ, который я пытаюсь найтичтобы получить его дескриптор
То, что я пытаюсь сделать, это получить дескриптор кнопки, на которую я пытаюсь нажать.однако есть два URL-адреса: 1-й - это основной URL-адрес, который находится в окне, а 2-й - это URL-адрес внутри окна (когда вы щелкаете правой кнопкой мыши> Правильные кнопки, URL-адрес отличается от основных окон).Также это другой или 2-й HTML-документ (примечание: здесь нет iframe / frame.)
только 2-й URL, то есть я не могу получить дескриптор, чтобы я мог контролировать его элементы.
Я уже попробовал некоторые коды ниже, чтобы получить все ручки.
ConnectURL "Secondary URL"
GetTheWindowHandle "IEFrame", "Secondary URL - Internet Explorer", hwndp
SetForegroundWindow hwndp
Sub ConnectURL(strURL As String)
On Error Resume Next
Set sws = New SHDocVw.ShellWindows
jar = sws.Count - 1
If jar < 0 Then
MsgBox "There's no active IE or window Explorer", vbInformation, "Pop-out"
Set sws = Nothing
Exit Sub
End If
n = 0
Do Until (n > 5000)
If (Left(sws.Item(n).LocationURL, Len(strURL)) = strURL) Then
If err.Number = 0 Then
Exit Do
End If
err.Clear
End If
n = n + 1
Loop
Set ieDoc = sws.Item(n).document
sws.Item(n).Visible = True
Set ieLoad = sws.Item(n)
End Sub
Function GetTheWindowHandle(C`enter code here`lassName As String, toSearch As String, handle As Long)
'Get Handle of window
tempHandle = 0
tempHandle = FindWindowEx(0, tempHandle, ClassName, vbNullString)
Do While tempHandle <> 0 'while handle is not seen
GetNameOfWindowByHandle tempHandle
If InStr(1, TextResult, toSearch) > 0 Then 'Check if Window title is similar
handle = tempHandle 'capture handle
Exit Do
End If
tempHandle = FindWindowEx(0, tempHandle, ClassName, vbNullString)
Loop
End Function
Function GetNameOfWindowByHandle(myHwnd As Long)
'capture the title of the window
Dim sbuffer As Long
Dim lresult As String
sbuffer = SendMessage(myHwnd, WM_GETTEXTLENGTH, 0, vbNullString)
sbuffer = sbuffer + 1
TextResult = Space$(sbuffer)
lresult = SendMessage(myHwnd, WM_GETTEXT, sbuffer, ByVal TextResult)
End Function
Example below
<div class="slit-item-active" id="reportsTab" onclick="openReportExplorer();"><div class="nav-icon3"></div><span id="reportsTabText">Reports</span></div>
this html code is on the button with the 2nd URL that I'm trying to get it's handle so i can use my code:
iedoc.getelementbyid("reportsTab").click
or
waiting = 0
Do While waiting = 0
For Each obj1 In ieDoc.getElementById("reportsTab").getElementsByTagName("span")
Debug.Print obj1.innerText
If Trim(obj1.innerText) = "Reports" Then
obj1.Click
ieLoading 2000
waiting = 1
Exit For
End If
Next
Loop