luckyluke Posted May 12, 2009 Share Posted May 12, 2009 i'm trying to do a post in blogger.com via autoit but it not working in writing post. expandcollapse popup<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="http://testscrollmenu.blogspot.com/" 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? Link to comment Share on other sites More sharing options...
Juvigy Posted May 12, 2009 Share Posted May 12, 2009 $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 Link to comment Share on other sites More sharing options...
luckyluke Posted May 12, 2009 Author Share Posted May 12, 2009 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? Link to comment Share on other sites More sharing options...
Juvigy Posted May 12, 2009 Share Posted May 12, 2009 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 ? Link to comment Share on other sites More sharing options...
luckyluke Posted May 12, 2009 Author Share Posted May 12, 2009 Yes, can you do it? Link to comment Share on other sites More sharing options...
DaleHohm Posted May 12, 2009 Share Posted May 12, 2009 $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 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 More sharing options...
luckyluke Posted May 13, 2009 Author Share Posted May 13, 2009 Thank Dale, i will try it, but can you tell me how to view the messages in the console? Link to comment Share on other sites More sharing options...
DaleHohm Posted May 13, 2009 Share Posted May 13, 2009 Edit your script using the SciTe editor installed with AutoIt and run your script with the F5 key. 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 More sharing options...
Juvigy Posted May 13, 2009 Share Posted May 13, 2009 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:) Link to comment Share on other sites More sharing options...
DaleHohm Posted May 13, 2009 Share Posted May 13, 2009 @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 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 More sharing options...
luckyluke Posted May 15, 2009 Author Share Posted May 15, 2009 @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 Link to comment Share on other sites More sharing options...
DaleHohm Posted May 15, 2009 Share Posted May 15, 2009 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 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 More sharing options...
luckyluke Posted May 16, 2009 Author Share Posted May 16, 2009 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. Link to comment Share on other sites More sharing options...
DaleHohm Posted May 16, 2009 Share Posted May 16, 2009 (edited) 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 May 16, 2009 by DaleHohm 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 More sharing options...
luckyluke Posted May 17, 2009 Author Share Posted May 17, 2009 nice!, it's working, you are great, thanks Dale Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now