Jump to content

Recommended Posts

Posted (edited)

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...

Posted

@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...

Posted

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

 

Posted

@Danp2 The _IEFrameGetObjByName function did not return me anything , but I could workaround using _IEFrameGetCollection.

Thank you for your help. I will paste working code once I finish validating it by getting table inside my html page.

 

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

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
×
×
  • Create New...