Jump to content



Photo

Help me to send text to textarea in HTML?


  • Please log in to reply
14 replies to this topic

#1 luckyluke

luckyluke

    Seeker

  • Active Members
  • 39 posts

Posted 12 May 2009 - 06:12 AM

i'm trying to do a post in blogger.com via autoit but it not working in writing post.

Plain Text         
<div id="body"><form action="/post-create.do" method="POST" name="stuffform" id="stuffform" onsubmit="return checkForTrAndSubmitForm();"><input type="hidden" name="security_token" value="AOuZoY4mAgsdGhd7TaR4g_aVHXOb7LDC0Q:1242104600100"> <div id="statusmsg" style="display: none;"><h3 class="error">LỖI</h3> <div id="errormsgdiv"></div> </div> <input type="hidden" name="blogID" value=""> <input type="hidden" name="blogURL" value="<a href='http://testscrollmenu.blogspot.com/' class='bbc_url' title='External link' rel='nofollow external'>http://testscrollmenu.blogspot.com/"</a> id="blogURL"> <input type="hidden" name="toggleTime" value="1"> <input type="hidden" name="editorModeDefault" value="1"> <script type="text/javascript">   document.write("\x3cinput type\x3d\x22hidden\x22 name\x3d\x22javascriptEnabled\x22 value\x3d\x22true\x22\x3e"); </script> <noscript><input type="hidden" name="javascriptEnabled" value="false"></noscript> <input type="hidden" name="hideAutosaveTooltip" value="false"> <input type="hidden" name="changeLanguage" value="false"> <input name="securityToken" type="hidden" value="_HI7x7fezfMNm_zVeKN-C-to_ac:1242104600140"> <input type="hidden" name="postID" id="postID" value=""> <div style="width:90%;"><table cellpadding="5" cellspacing="0" border="0" id="titles"><tr><th><label for="f-title">Tiêu đề:</label></th> <td><div class="errorbox-good"><input type="text" name="title" value="" id="f-title" tabindex="1" class="text" onkeyup="setPreviewTitle(getTitle());" maxlength="150" dir="ltr" size="48"></div></td></tr> </table> <input type="hidden" name="enclosuresDataPresent" value="true"> <div id="enclosures"><table id="enclosures-table" border="0" cellspacing="0" cellpadding="2"><caption>Tệp đính kèm</caption> <thead><tr><th scope="col">URL</th> <th scope="col" nowrap>Loại MIME</th></tr></thead> <tbody> <tr id="new-enclosure-row"><td><div class="errorbox-good"><input type="text" name="enclosureUrl.new" value="" class="url text" dir="ltr" onchange="BLOG_suggestMimeType(this)" onblur="BLOG_suggestMimeType(this)"></div> <div class="error"></div> <div class="error"></div></td> <td><div class="errorbox-good"><input type="text" name="enclosureMimeType.new" value="" class="mime-type text" dir="ltr"></div> <input type="hidden" name="enclosureLength.new" value=""></td></tr></tbody> <tfoot><tr><td><div class="errorbox-good"></div> <script type="text/javascript">   document.write("\x3ca href\x3d\x22#\x22 onclick\x3d\x22BLOG_newEnclosure(); return false;\x22\x3eTh\xeam li\xean k\u1ebft \u0111\xednh k\xe8m\x3c/a\x3e"); </script></td> <td style="text-align:right"></td></tr></tfoot></table> <input type="hidden" name="enclosureCount" value="0" id="enclosure-counter"></div> /****************** this is for write post?****************/ <div id="RichEdit"><textarea name="postBody" rows="17" cols="47" id="textarea" wrap="soft" tabindex="5" dir="ltr"></textarea></div> <div id="labels-container"><table><tr><td rowspan="2" style="width: 15px"><img id="optionsTriangle" src="../img/triangle_ltr.gif" onclick="togglePostOptions()" alt=""></td> <td rowspan="2"><a href="#" onclick="togglePostOptions(); return false">Tuỳ chọn Bài đăng</a></td> <td width="1%" style="white-space:nowrap"><div id="label-directions"><b>Nhãn cho bài đăng này:</b><br> <span style="color: #555">ví dụ: <b>xe scutơ, kỳ nghỉ, mùa thu</b></span></div></td> <td width="1%" style="white-space: nowrap"><input type="text" name="postLabels" value="" autocomplete="off" id="post-labels" tabindex="6" dir="ltr"> </td></tr> <tr><td colspan="2"><div id="all-labels" style="display:none;">Tất cả Nhãn: <span class="label-list"></span></div></td></tr></table></div> <div id="postoptions"><div class="minwidth"></div> <div class="clear"></div> <div class="left-section"><div class="clear"></div> <label for="toggleComments"><b>Nhận xét của Người đọc</b></label> <br> <input type="radio" name="commentsMode" checked value="ON" id="cYes"> <label for="cYes">Cho phép</label><br> <input type="radio" name="commentsMode" value="HIDE" id="cNo"> <label for="cNo">Không cho phép</label> <br> <div class="clear"></div></div>


i tried this code:

$oForms = _IEFormGetObjByName ($oIE, "stuffform") ;$elements = _IEFormElementGetCollection($oForms,17) $opostBody = _IEFormElementGetObjByName ($oForms, "postBody") _IEFormElementSetValue ($opostBody, "hi all")

But not working, how to do it?





#2 Juvigy

Juvigy

    Experimental Drugs Abuser

  • Active Members
  • PipPipPipPipPipPip
  • 1,243 posts

Posted 12 May 2009 - 08:32 AM

$oForms = _IEFormGetObjByName ($oIE, "stuffform") this is wrong.

$oForms = _IEFormGetObjByName ($oIE, "form") this gets all the "form" objects. If you want "input" objects just replace it.After that you can see the form name for example like this:

oForms["index"].name

#3 luckyluke

luckyluke

    Seeker

  • Active Members
  • 39 posts

Posted 12 May 2009 - 10:00 AM

Do you think about this code

$oForms = _IEFormGetObjByName ($oIE, "stuffform") $oTitle = _IEFormElementGetObjByName ($oForms, "title") _IEFormElementSetValue ($oTitle,"This is test post")


It's working, but can not working for postBody element, i dont know why?

#4 Juvigy

Juvigy

    Experimental Drugs Abuser

  • Active Members
  • PipPipPipPipPipPip
  • 1,243 posts

Posted 12 May 2009 - 10:34 AM

Do you want to enter text here :
<div id="RichEdit"><textarea name="postBody" rows="17" cols="47" id="textarea" wrap="soft" tabindex="5" dir="ltr"></textarea></div> Or where ?

#5 luckyluke

luckyluke

    Seeker

  • Active Members
  • 39 posts

Posted 12 May 2009 - 04:49 PM

Yes, can you do it?

#6 DaleHohm

DaleHohm

    Think of IE as an API...

  • MVPs
  • 5,886 posts

Posted 12 May 2009 - 05:33 PM

$oForms = _IEFormGetObjByName ($oIE, "stuffform") this is wrong.

$oForms = _IEFormGetObjByName ($oIE, "form") this gets all the "form" objects. If you want "input" objects just replace it.After that you can see the form name for example like this:

oForms["index"].name

@Juviqy -- You obviously do not know how to use the IE.au3 library and I've seen a lot of bad advice and inforamtion comming from you lately. Please stop. Everything you've told this person is wrong. Please take the time to learn before you try to sound like an authority.


@luckyluke, please run your code inside SciTe and pay attention to the messages that are written to the console. You are on the right track with your code.

Dale
IE.au3 issues with Vista - Workarounds, Automate input type=file (Related)SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=YFree Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curlMSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model,Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbeddedFind and harvest Enum constants for COM codeAutoIt Snippets Database - you too can contribute!Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your troubleDoesn'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?

#7 luckyluke

luckyluke

    Seeker

  • Active Members
  • 39 posts

Posted 13 May 2009 - 02:19 AM

Thank Dale, i will try it, but can you tell me how to view the messages in the console?

#8 DaleHohm

DaleHohm

    Think of IE as an API...

  • MVPs
  • 5,886 posts

Posted 13 May 2009 - 03:12 AM

Edit your script using the SciTe editor installed with AutoIt and run your script with the F5 key.

Dale
IE.au3 issues with Vista - Workarounds, Automate input type=file (Related)SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=YFree Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curlMSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model,Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbeddedFind and harvest Enum constants for COM codeAutoIt Snippets Database - you too can contribute!Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your troubleDoesn'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?

#9 Juvigy

Juvigy

    Experimental Drugs Abuser

  • Active Members
  • PipPipPipPipPipPip
  • 1,243 posts

Posted 13 May 2009 - 08:47 AM

Well Dale i am not an expert like you but just try to help - didnt quite get what the user wants exactly . But that is what are forums for right?

@luckyluke,
If you want to write in the :
<div id="RichEdit"><textarea name="postBody" rows="17" cols="47" id="textarea" wrap="soft" tabindex="5" dir="ltr"></textarea>
You can try something like


$oDoc = _IEDocGetObj($oIE)
$oArray = $oDoc.getElementsByTagName("textarea")

for $element in $oArray
if $element.name="postBody" and $element.id="textarea" then
$element.Value="some text that you entered"
EndIf
next

@Dale please tell me if my code is wrong as i want to improve:)

#10 DaleHohm

DaleHohm

    Think of IE as an API...

  • MVPs
  • 5,886 posts

Posted 13 May 2009 - 01:35 PM

@Juviqy - your latest code will work, but there are easier ways to do it in IE.au3.

Your previous post was a mess and you told the OP he was wrong when he was on the right track.

All things equal, the following two lines should do the trick:

$oTextArea = _IEGetObjByName($oIE, "postBody")
_IEFormElementSetValue($oTextArea, "my text")

If there is more than one element with the name of postBody, there is an optional index parameter to _IEGetObjByName. If this "doesn't work" there should be messages written to the SciTe console to help him.

Dale
IE.au3 issues with Vista - Workarounds, Automate input type=file (Related)SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=YFree Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curlMSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model,Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbeddedFind and harvest Enum constants for COM codeAutoIt Snippets Database - you too can contribute!Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your troubleDoesn'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?

#11 luckyluke

luckyluke

    Seeker

  • Active Members
  • 39 posts

Posted 15 May 2009 - 08:30 AM

@DaleHohm:
I dont see error or warning messages in console, even when i use this code:

$oForms = _IEFormGetObjByName ($oIE, "stuffform") $elements = _IEFormElementGetCollection($oForms) $num = @extended for $i = 0 to $num - 1         $oQuery = _IEFormElementGetCollection ($oForm, $i)         _IEFormElementSetValue ($oQuery, "this is test post") next


and i see nothing in input box of my new post in blogger.

Maybe Autoit cant use in this case.

@Juviqy:
$oDoc = _IEDocGetObj($oIE) $oArray = $oDoc.getElementsByTagName("textarea") for $element in $oArray if $element.name="postBody" and $element.id="textarea" then $element.Value="some text that you entered" EndIf next


It dont work anymore
thank

#12 DaleHohm

DaleHohm

    Think of IE as an API...

  • MVPs
  • 5,886 posts

Posted 15 May 2009 - 10:53 PM

You aren't getting to the correct form element then (or perhaps not even to the right form). Can't help much more without being abel to see the live site.

Dale
IE.au3 issues with Vista - Workarounds, Automate input type=file (Related)SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=YFree Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curlMSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model,Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbeddedFind and harvest Enum constants for COM codeAutoIt Snippets Database - you too can contribute!Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your troubleDoesn'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?

#13 luckyluke

luckyluke

    Seeker

  • Active Members
  • 39 posts

Posted 16 May 2009 - 10:05 AM

maybe you say true, but when i use _IEFormGetCollection i get only one form is "stuffform". If you have a gmail account, you can try blogger.com and create a blog and post a new post.

#14 DaleHohm

DaleHohm

    Think of IE as an API...

  • MVPs
  • 5,886 posts

Posted 16 May 2009 - 02:23 PM

If you look at the site with DebugBar you'll quickly see what is wrong. There is a textarea there, but it is not displayed:

<TEXTAREA id=textarea dir=ltr style="DISPLAY: none" tabIndex=5 name=postBody rows=17 cols=47></TEXTAREA>

The area that displays text is instead an iFrame:

<IFRAME id=richeditorframe style="DISPLAY: block" tabIndex=1></IFRAME>

#include <IE.au3> $oIE = _IEAttach("Blogger") $oFrame = _IEFrameGetCollection($oIE, 0) _IEBodyWriteHTML($oFrame, "Good Morning")


Dale

Edit: typos

Edited by DaleHohm, 16 May 2009 - 02:25 PM.

IE.au3 issues with Vista - Workarounds, Automate input type=file (Related)SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=YFree Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curlMSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model,Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbeddedFind and harvest Enum constants for COM codeAutoIt Snippets Database - you too can contribute!Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your troubleDoesn'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?

#15 luckyluke

luckyluke

    Seeker

  • Active Members
  • 39 posts

Posted 17 May 2009 - 03:02 AM

nice!, it's working, you are great, thanks Dale




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users