Jump to content
MakzNovice

_IEFrameGetObjByName behaving differently for two scenarios

Recommended Posts

Hello Experts,

I am working on custom application details of which I am unable to share.

But here is statement of my problem, I have two IE windows one window with Title "Parent " and other with "TableEdit", but for some reason when I get WinList they are shown as 2 processes each. ( see attached image)

Since my most important motive is to modify table data in 'TableEdit' I try to access the table in it

My code snippet is 

***********************************************************************************************

$searchString = "TableEdit"
Local $aList = WinList("[REGEXPTITLE:(?i)(.*Internet Explorer.*)]")
_ArrayDisplay($aList)
For $i = 1 To $aList[0][0]
    If $aList[$i][0] <> "" And BitAND(WinGetState($aList[$i][1]), 2) Then
        ;MsgBox($MB_SYSTEMMODAL, "", "Title: " & $aList[$i][0] & @CRLF & "Handle: " & $aList[$i][1])
        If 0 <> StringInStr($aList[$i][0],"TableEdit") Then
            $objEditIE = _IEAttach ($aList[$i][1])
            ExitLoop
        EndIf
    EndIf
Next

WinActivate($objEditIE)

$oPageContentListFrame = _IEFrameGetObjByName($objEditIE, "iframe_1")
$iNumFrames = @extended
MsgBox(0,"Got pagecontent",@error) ; returns 3, indicating invalid data type
MsgBox(0,"Number of Frame",$iNumFrames) ; returns 1, expected value is 1 

***********************************************************************************************

and If I do code as below the return value is different

$searchString = "TableEdit"

 $objEditIE = _IEAttach ($searchString, "title")

WinActivate($objEditIE)

$oPageContentListFrame = _IEFrameGetObjByName($objEditIE, "iframe_1")
$iNumFrames = @extended
MsgBox(0,"Got pagecontent",@error) ; returns 0
MsgBox(0,"Number of Frame",$iNumFrames) ; returns 0. expected value is 1

***********************************************************************************************

What is wrong with my code? 

Why do I see two process each for IE for each window?

 

WinListImage.bmp

Edited by MakzNovice

It doesn't get easier, you just get better...

Share this post


Link to post
Share on other sites

@Danp2 Thank you for suggestion. I modified the code as suggested by you 

My new code now looks like as below 

$searchString = "TableEdit"
Local $aList = WinList("[REGEXPTITLE:(?i)(.*Internet Explorer.*)]")
_ArrayDisplay($aList)
For $i = 1 To $aList[0][0]
    If $aList[$i][0] <> "" And BitAND(WinGetState($aList[$i][1]), 2) Then
        ;MsgBox($MB_SYSTEMMODAL, "", "Title: " & $aList[$i][0] & @CRLF & "Handle: " & $aList[$i][1])
        If 0 <> StringInStr($aList[$i][0],"TableEdit") Then

            $hWnd = WinGetHandle($aList[$i][1])
            $objEditIE = _IEAttach ($hWnd,"hwnd")
            MsgBox(0,"@Error",@error) ; returns 0, which means _IEAttach is OK
            ExitLoop
        EndIf
    EndIf
Next

WinActivate($objEditIE) ;This does not activate my TableEdit Window, infact does nothing 

$oPageContentListFrame = _IEFrameGetObjByName($objEditIE, "iframe_1")
$iNumFrames = @extended
MsgBox(0,"Got pagecontent",@error) ; returns 0, indicating this is ok
MsgBox(0,"Number of Frame",$iNumFrames) ; returns 0, expected value is 1

******************************************************************************

I think the problem is I get wrong Window, but I am not sure why I have two TableEdit process instead of one ?


It doesn't get easier, you just get better...

Share this post


Link to post
Share on other sites

I think the documentation is wrong for _IEFrameGetObjByName. It doesn't appear to set @extended to the number of frames.

FYI, here's a rewrite of your code that anyone can use to test this --

#include <IE.au3>
#include <Array.au3>

Local $oIE = _IE_Example("iframe")
Local $searchString = "_IE_Example"
Local $objEditIE

Local $aList = WinList("[REGEXPTITLE:(?i)(.*Internet Explorer.*)]")
_ArrayDisplay($aList)
For $i = 1 To $aList[0][0]
    If $aList[$i][0] <> "" And BitAND(WinGetState($aList[$i][1]), 2) Then
        If 0 <> StringInStr($aList[$i][0], $searchString) Then
            $objEditIE = _IEAttach ($aList[$i][1], "hwnd")
            ExitLoop
        EndIf
    EndIf
Next

If IsObj($objEditIE) Then
    $oPageContentListFrame = _IEFrameGetObjByName($objEditIE, "iFrameOne")
    consolewrite("@error="&@error&@CRLF&"@extended=" & @extended & @CRLF)
EndIf

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • By zuladabef
      I want to set the value of a input, but I only have the input name and input id.  I cannot find a form in the source.  Form collection does not return any results.  
      Is there a way to use FormElementSetValue without a form name? Can I use _IEGetObjByName or _IEGetObjById?  If so, how do I set the value once I have the object? Where do I go from here? Local $oIE = _IEAttach("[Website Goes Here"]) Local $oForm = _IEFormGetCollection($oIE, 1) Local $oQuery = _IEFormElementGetCollection($oForm, 4) _IEFormElementSetValue($oQuery, "Set it to this")  
    • By Seminko
      Hey there,
      below function returns an "object collection" (not sure if that's the correct term) of 'a' elements grabbed from within //*[@id="J_DetailMeta"].
      However, I need the returned collection not to include objects with 'aria-disabled = true'. Is there a way of removing specific objects from such a collection?
      Func GetObjectList($sPicker) $oDetailMeta = _IEGetObjById($oIE, "J_DetailMeta") If Not @error Then $tags = $oDetailMeta.GetElementsByTagName("ul") For $tag in $tags $data_ID_value = $tag.GetAttribute("data-property") If $sPicker = "color" Then If $data_ID_value = '????' Or $data_ID_value = "????" Then $oReturnList = $tag.GetElementsByTagName("a") EndIf ElseIf $sPicker = "network" Then If $data_ID_value = '????' Then $oReturnList = $tag.GetElementsByTagName("a") EndIf ElseIf $sPicker = "storage" Then If $data_ID_value = '????' Then $oReturnList = $tag.GetElementsByTagName("a") EndIf EndIf Next EndIf Return $oReturnList EndFunc $oColorList = GetObjectList("color") For $oColor In $oColorList If StringInStr($oColor.GetAttribute("aria-disabled"), "true") <= 0 Then ; remove object from the collection ??? EndIf Next  
    • By careca
      Hi, i feel im close to getting it to work, but there must be something im missing that's probably easy for you experts.
      #include <IE.au3> #include <File.au3> #include <MsgBoxConstants.au3> $Visible = 1 Local $oIE $oIE = _IECreate("https://beemp3s.net/mp3-download.html", 0, $Visible, 1, 1) _IELoadWait($oIE) If $oIE <> @error Then ;_ArrayText() _QuerySite('Finding Hope - Without You') ;_IEQuit($oIE) ;Exit Else MsgBox(64 + 262144, 'Fail', 'Could not create a new window') EndIf ;============================================================================= Func _QuerySite($Name) Local $oIE_ObjectToSearch = _IEGetObjById($oIE, 'query') _IEDocInsertText($oIE_ObjectToSearch, $Name) Local $oIE_ObjectToClick = _IEGetObjById($oIE, "search-action") _IEAction($oIE_ObjectToClick, 'click') _IELoadWait($oIE, 2000) ;============================================================================= Local $oSubmitClick = _IEGetObjById($oIE, "col-md-12") _IEAction($oSubmitClick, "click") _IELoadWait($oIE, 2000) ;============================================================================= Local $oBtns = _IETagNameGetCollection($oIE, "div") For $oBtn In $oBtns If String($oBtn.classname) = "col-md-12" Then If String($oBtn.innertext) = "Download / Play" Then ConsoleWrite($oBtn.innertext & @CRLF) _IEAction($oBtn, 'click') EndIf EndIf Next ;============================================================================= ;Local $oElements = _IETagNameAllGetCollection($oIE) ;For $oElement In $oElements ; If $oElement.id Then MsgBox($MB_SYSTEMMODAL, "Element Info", "Tagname: " & $oElement.tagname & @CRLF & "id: " & $oElement.id & @CRLF & "innerText: " & $oElement.innerText) ;Next ;============================================================================= ;_IEQuit($oIE) ;Exit ;============================================================================= EndFunc ;==>_QuerySite ;============================================================================= Func _ArrayText() If FileExists('Titles.txt') Then Local $FO = FileOpen('Titles.txt') Local $R2A = FileReadToArray($FO) Local $iLineCount = @extended FileClose($FO) For $f = 0 To $iLineCount - 1 ConsoleWrite($f & ' - ' & $R2A[$f] & @CRLF) _QuerySite($R2A[$f]) Next Else MsgBox(64 + 262144, 'Fail', 'Could not find the file Titles.txt') EndIf EndFunc ;==>_ArrayText ;============================================================================= The idea is to get into this site, write into the search and click, which i did, but now the problem is clicking in any of the buttons in the results page, im looking for a way to click the first one, it always matches to what i want, so no need to fiddle around.
      Site
      Thanks for help in advance.

    • By yoschga
      is there a possibility to let ie.au3 click into a form? i use on a project where i need to click into a form where items are loaded just writing it in or fill the form is no option
       

    • By RamaKrishna9
      What are the minimum system requirements(like Windows OS version, IE browser version, etc,.) for IE.au3(3.3.14.2) to work properly?
×
×
  • Create New...