Jump to content
Sign in to follow this  
sammy1983

Error using _IEFormElementSetValue

Recommended Posts

sammy1983

Hi,

Please take a look at the screenshot. This is a iFrame and got the iFrame info using the below code:

Local $oFrames = _IEFrameGetCollection($oIE)
Local $iNumFrames = @extended
Local $sTxt = $iNumFrames & " frames found" & @CRLF & @CRLF
Local $oFrame = 0
For $i = 0 To ($iNumFrames - 1)
$oFrame = _IEFrameGetCollection($oIE, $i)
$sTxt &= _IEPropertyGet($oFrame, "innertext") & @CRLF
Next
MsgBox($MB_SYSTEMMODAL, "Frames Info", $sTxt)

There is only 1 iFrame named "0".

 Here is my code:

$oFrame = _IEFrameGetCollection($oIE, 0)
$oInput = _IEGetObjById($oFrame, "tinymce")
_IEFormElementSetValue($oInput, "Test")

and the output is:

--> IE.au3 T3.0-1 Error from function _IEFormElementSetValue, $_IEStatus_InvalidObjectType

Can someone help me with this? Thanks.

post-80752-0-60461600-1395264589_thumb.j

Share this post


Link to post
Share on other sites
sammy1983

It's an Internal URL. You will not be able to access that, however, I can provide any additional information. Thanks.

Providing the URL will be breach of company's security policy. Hope you understand.

Also, just trying to understand that how this could be related to URL. The script is able to recognize the iFrame as well, it's just not setting the text.

Edited by sammy1983

Share this post


Link to post
Share on other sites
Danp2

There is only 1 iFrame named "0".

 

The frame is named "0" or there is only one frame? Or there is only one frame *and* it's name is "0"? ;-)

FWIW, the code you posted retrieves the first frame, not a frame named "0".

Edited by Danp2

Share this post


Link to post
Share on other sites
sammy1983

Below code is used to get Frame info:

Local $oFrames = _IEFrameGetCollection($oIE)
Local $iNumFrames = @extended
Local $oFrame = 0
For $i = 0 To ($iNumFrames - 1)
    $oFrame = _IEFrameGetCollection($oIE, $i)
    $oInput = _IEGetObjById($oFrame, "tinymce")
        If @error Then
            ConsoleWrite("Frame number " & $i & ": Object not found! " & @CRLF)
        Else
            ConsoleWrite("Frame number " & $i & ": Object found! " & @CRLF)
        EndIf
Next

The output is:

--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
Frame number 0: Object found! 
--> IE.au3 T3.0-1 Error from function _IEFormElementSetValue, $_IEStatus_InvalidObjectType
Edited by sammy1983

Share this post


Link to post
Share on other sites
sammy1983

The frame is named "0" or there is only one frame? Or there is only one frame *and* it's name is "0"? ;-)

FWIW, the code you posted retrieves the first frame, not a frame named "0".

 

there is only one frame *and* it's name is "0"  :) 

Share this post


Link to post
Share on other sites
sammy1983

<body id="tinymce" class="mceContentBody " onload="window.parent.tinyMCE.get('richContent').onLoad.dispatch();" contenteditable="true" dir="ltr"><br data-mce-bogus="1"></body>

Share this post


Link to post
Share on other sites
sammy1983

Have you reviewed >this post?

 

Ok.. so I reviewed the post and below code did Magic.

$oFrame = _IEFrameGetCollection($oIE, 0)
_IEBodyWriteHTML($oFrame, $text)
However, now another problem is this. 
Local $hEdit

    ; Create GUI
    GUICreate("Details", 900, 500)
    $hEdit = GUICtrlCreateEdit("", 2, 2, 895, 495)
    GUICtrlSetFont(-1, 9, 700)
    GUICtrlSetColor(-1, $COLOR_BLACK)
    ;GUISetState(@SW_SHOW)

    ; Set Text
    _GUICtrlEdit_SetText($hEdit, "What is the changes?" & @CRLF & @CRLF & _
            "Who will make the change?")

        $text = _GUICtrlEdit_GetText($hEdit)

Though I have given @CRLF & @CRLF, the output is shown in the screenshot. Can this also be recitified?

I assume this is because it's writing in HTML format and not in regular Text format. Any ideas?

post-80752-0-00937000-1395268123_thumb.j

Edited by sammy1983

Share this post


Link to post
Share on other sites
sammy1983

I'm confused. Are you still trying to update the tinymce control? If so, I would try <BR> or <P> instead of @CRLF since as you indicated you are writing in HTML format.

 

Yes. That made it. I replaced @CRLF with <br> and now I am able to publish text in "tinymce" element using below code. Thanks Danp2 for all your efforts.

$oFrame = _IEFrameGetCollection($oIE, 0)
_IEBodyWriteHTML($oFrame, $text)

where $text = _GUICtrlEdit_GetText($hEdit)

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
Sign in to follow this  

×