Jump to content

Issue with IE Object/Form Retrieval


Recommended Posts

Hello! Unfortunately I forgot my old username as I have not logged in in ages... so had to create another one. Apologies.

Anyway, I am having significant issues adding text to a weird IE Form object. It is a text area, but its of type:

<textarea name="html" id="html" class="mceEditor"></textarea>

so, when I do the normal tactic of retrieving the form or tag collection, I can pinpoint the name = "html", but I cannot "focus" or propertyset this form element.

I even attempted to do the _IEAction focus and click options, but since this is an mceEditor object, I cannot get it to add text to the text area. A simple "click" and Send() also doesn't work...

so any help would be MADLY appreciated.

Edited by JacobA

Enjoy making solutions for points-2-shop

Link to comment
Share on other sites

These type of editors typically use iFrames rather than textareas for the content region. My guess is taht if you look more carefully, you'll find one.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

The actual object I am attempting to edit is a textarea but of type HTML (mceEditor). Consequently, it throws the INPUT TYPE=FILE issue with my attempted focus work-arounds. Using the basic focus work-around itself, also doesn't work (as mentioned above). I do not think it is an iframe, although that was my first guess also. You can see the specific form I am looking at, at the URL posted. Any help would be great... getting really frustrated here.

Enjoy making solutions for points-2-shop

Link to comment
Share on other sites

As an addition - here is more of the HTML that contains the textarea I am trying to get to:

<td class="formInputLabel" id="editorLabelCell">
            Article Body            &nbsp;&nbsp;
            <a class="smoothbox formWhatsThisLink" title="How do I use the Online Editor?" href="#TB_inline?height=450&width=480&inlineId=editorHelpDiv">Online Editor Help</a>

        </td>
    </tr>
    <tr>
        <td>
            <table cellpadding="0" cellspacing="0" border="0">
            <tr>
                <td id="editorInputCell" style="height:100%;">
                    <textarea name="html" id="html" class="mceEditor"></textarea>

                </td>
                <td  style="height:100%;">
                    <div class="suggestImagesButtonDiv">
                        <input class="smallButton" id="getImageSuggestionsButton" type="button" onclick="$('suggestPicsDiv').innerHTML=''; doPaneAction('post','submit','suggest-pics','suggestPicsDiv',{'search-str':$('title').value +' '+ $('description').value +' '+ $('tags').value +' '+ tinyMCE.activeEditor.getContent()},true);" value="Get Image Suggestions">
                    </div>
                    <div id="suggestPicsDiv" class="suggestedPicsDiv"></div>
                </td>       
            </tr>
            <tr><td></td></tr>

            </table>
        </td>

And again, I have tried the normal routes because the name is quite obviously "html". I have tried many things - I will include my messy bit of code below - the things I have tried are actually commented, and I don't know where to go....

$colTags = _IETagNameGetCollection($oIE_4, "textarea") 
            For $oTag_T2 In $colTags     
                MsgBox(0, "textarea", $oTag_T2.name)
                if $oTag_T2.name == "description" Then
                    ;CLipPut($art_title_complete)
                    _IEFormElementSetValue($oTag_T2, $introduction_inserter_1)
                    ;_IEAction($oTag,"paste")
                    sleep(1000)
                    ;_ClipBoard_Empty()
                EndIf
                if $oTag_T2.name == "html" Then
                    
                    ;$html_input = _IEFormGetObjByName($oTag_T2, "textarea")
                    ;$this = _IEFormElementGetObjByName($html_input, "html")
                    
                    ;$test = _IEPropertyGet($oTag_T2, "innerhtml")
                    ;_IEPropertySet($oTag_T2, "innerhtml", "this is it!")
                                
                    ;ConsoleWrite($test)
                    ;ConsoleWRite("FOUND IT!!!!!")
                    
                    ;ClipPut("checking to see if this works")
                    ;_IEFormElementSetValue($oTag_T2, "cocker_pooper")
                    ;_IEAction($oTag_T2, "focus")
                    
                    _IEAction($oTag_T2, "click")
                    sleep(250)
                    send("hi")              
                    ;Send("this is going to rock")
                    sleep(1000)
                    ;_ClipBoard_Empty()
                EndIf               
            Next

I have also tried the basic "focus" route and that also fails.....

Enjoy making solutions for points-2-shop

Link to comment
Share on other sites

The URL you provide requires a login.

You can go here to see a demo of tinyMCE - it uses an iFrame... See if you can work with this site: http://tinymce.moxiecode.com/tryit/full.php

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

:unsure: im loosing it over here... this is the worlds most frustrating thing, and it should be so simple given the _IE functions and how easy it is to grab inputs and other forms... Edited by JacobA

Enjoy making solutions for points-2-shop

Link to comment
Share on other sites

I cannot... is there a a precedent for using autoit3 to modify mce?

You cannot? And why is that?

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

I'm trying to tell you, the tinyMCE site I pointed you to demonstrates how tinyMCE uses an iFrame and you must update the contents of the docment in the iFrame in order to make a change in the editor.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Ok fair enough... so how would I go about doing that? Would it be via the _IE*doc functions? I could really use some help on this.. I wish it was as simple as locating and setting a value to the textarea....

As an update - I re-read the source, and the MCE on the page I am trying to modify is actually listed as a tinymc.js. I can see the javascript and everything, but its huge.

Edited by JacobA

Enjoy making solutions for points-2-shop

Link to comment
Share on other sites

You'll actually find some discussion of this if you search the forum for TinyMCE.

#include <IE.au3>
$oIE = _IECreate("http://tinymce.moxiecode.com/tryit/full.php")
$oFrame = _IEFrameGetCollection($oIE, 0)
_IEDocWriteHTML($oFrame, "This is not hard")

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

You'll actually find some discussion of this if you search the forum for TinyMCE.

#include <IE.au3>
$oIE = _IECreate("http://tinymce.moxiecode.com/tryit/full.php")
$oFrame = _IEFrameGetCollection($oIE, 0)
_IEDocWriteHTML($oFrame, "This is not hard")

Dale

Thanks Dale - I tried this before but for some reason it didn't work, but now it (partially) is!

What I have done (and it's not working 100% yet) was to first loop through the number of frames on the page to see how many there were. I found 2 (0,1). Changing index 1 does nothing, but 0 changes the text in the mceditor, yay (I first tried to use your debuggerbar to find the index of the editor, but couldn't). However, it somehow de-activated the ability to manually edit inside the editor? I mean, I can see the text in the mceditor after _IEDocWriteHTML'ing to its index, but now I can't click in there and type anymore. Did I do something wrong? I haven't clicked the submit button, but hope it will actually submit the correctly written text...

For before, simply _IEDocWriteHTML to a tag collection whos tag is $otag_t2.name = "html" (this is the mce editor) doesn't work - it writes the HTML in my entire IE object in my gui, changing the entire gui...

One further question - One of the components on the page is a "suggested images" area, that changes dynamically. I won't know the contents of it, but I do know the <td> tag it is located in (I used your DebugBar to find the exact location). Can I click in the middle of a <td> tag without knowing its contents and with the IE functions?

Edited by JacobA

Enjoy making solutions for points-2-shop

Link to comment
Share on other sites

I need to bump this...

I was able to change the mce as mentioned above, but when I hit "submit" it doesn't recognize anything that I entered within it, and removes it all. This does not happen obviously if I manually write material in the mce and submit it that way....

I suspected this was going to be an issue because after I _IEDocwritehtml it, I cannot click inside it any more, so something is getting messed up. :unsure:

UPDATE:

I added the html to my clipboard before sending it to the _IEDocwritehtml. The submit button doesnt work if I click the Submit button after using the _IEdoctwritehtml to post the html in the mce. HOWEVER, if I paste it from my clipboard instead, then hit submit, it does work... what is going on?

Edited by JacobA

Enjoy making solutions for points-2-shop

Link to comment
Share on other sites

I added the html to my clipboard before sending it to the _IEDocwritehtml. The submit button doesnt work if I click the Submit button after using the _IEdoctwritehtml to post the html in the mce. HOWEVER, if I paste it from my clipboard instead, then hit submit, it does work... what is going on?

Actually I was facing same issue. The solution I found was not to use _IEDocWriteHTML, since that will probably overwrite some iFramecode.

This works for me every time:

func readit()
        $oFrame = _IEFrameGetCollection($oie, 0)
        $i = _IEBodyReadHTML($oFrame)
        MsgBox(0,"",$i)
EndFunc

func writeit()
        $oFrame = _IEFrameGetCollection($oie, 0)
        _IEBodyWriteHTML($oframe, "<h1>Date: " & @MDAY & random(100,999,1) & "</h1>")
EndFunc

Notice use of _IEBodyWriteHTML which only updates the content between <body>..</body> of the iFrame. Basically where you write your content.

I am just a hobby programmer, and nothing great to publish right now.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...