Selenium Basic has examples of how to do this in Chrome, Firefox and IE. Hwnd = FindWindowEx(hParent, hwnd, vbNullString, vbNullString) GetWinInfo hwnd, intOffset + 1, OutputType GetWinInfo hwnd, intOffset + 2, OutputType GetWinInfo hwnd, intOffset + 3, OutputType ShtH.Range("a1").Offset(x, intOffset + 2) = Left$(strText, lngRet) ShtH.Range("a1").Offset(x, intOffset + 1) = Left$(strText, lngRet) ShtH.Range("a1").Offset(x, intOffset) = "N/A" LngRet = GetWindowText(hwnd, strText, 100) ShtH.Range("a1").Offset(x, intOffset) = hwnd ShtH.Range("a1").Offset(x, intOffset) = Left$(strText, lngRet) LngRet = GetClassName(hwnd, strText, 100) Hwnd = FindWindowEx(hParent, 0&, vbNullString, vbNullString) 'writes data to a sheet to be able to search for a specific objectÄim hwnd As Long, lngRet As Long, Y As Integer 'Sub to recursively obtain window handles, classes and text Private Sub GetWinInfo(hParent As Long, intOffset As Integer, OutputType As Integer) GetWinInfo CLng(HParentWind), 0, winOutputType.winHandleClassTitle Public Sub GetWindows(HParentWind As Variant) ' FindButton 'This is needed if there is a pop up window and you need to click a specific button ' GetWindows 0 'This is needed if there is a pop up window and you need to click a specific button Document.getElementsByName("GetFile").Item(0).Click Set IE = CreateObject("InternetExplorer.Application") Set shtH = Worksheets.Add(After:=Sheets(1)) 'Used a user defined type here rather than Enum so that it works on 97 Private Declare PtrSafe Function GetActiveWindow Lib "user32" () As Long (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Private Declare PtrSafe Function GetWindowText Lib "user32" Alias "GetWindowTextA" _ (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long Private Declare PtrSafe Function GetClassName Lib "user32" Alias "GetClassNameA" _ (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long Private Declare PtrSafe Function FindWindowEx Lib "user32" Alias "FindWindowExA" _ It really depends on the web site, but I have been able to do that with code like this, using MS IE
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |