Sign in to follow this  
Followers 0
chenxu

IE.au3 failed to set value of a form object, help me!

5 posts in this topic

The web page:

http://bbs.zhuodou.com/posttopic.aspx?forumid=24

sorry, it's in Chinese...

the page is to post a new topic of a forum, and I am trying to send a topic automaticly, but I failed to send text to the textarea of the page with the following code:

#include <GUIConstants.au3>
#include <IE.au3>

setLayout()
While 1
    Sleep(2000)
WEnd

Func setLayout()
    $winHeigh = 480
    $winWidth = 640
    $browserHeigh = $winHeigh
    $browserWidth = $winWidth
    $btnHeigh = 25
    $btnWidth = 80
    
    _IEErrorHandlerRegister ()
    $oIE = _IECreateEmbedded ()
    $guiHandle = GUICreate("test", $winWidth, $winHeigh, _
            (@DesktopWidth - $winWidth) / 2, (@DesktopHeight - $winHeigh) / 2, _
            $WS_CAPTION + $WS_SYSMENU + $WS_MINIMIZEBOX + $WS_VISIBLE + $WS_CLIPSIBLINGS)
    $GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, $browserWidth, $browserHeigh)
    
    _IENavigate ($oIE, "http://bbs.zhuodou.com/posttopic.aspx?forumid=24")
    _IELoadWait($oIE)
    $oForm = _IEFormGetObjByName ($oIE, "postform")
    $oText = _IEFormElementGetObjByName ($oForm, "title")
    _IEFormElementSetValue ($oText, "testing titile")
    
    $oText = _IEFormElementGetObjByName ($oForm, "message")
    _IEAction ($oText, "visible")
    _IEFormElementSetValue ($oText, "testing message")
    GUISetState()       ;Show GUI
EndFunc

Somebody help me please...

Share this post


Link to post
Share on other sites



We can't test it very well without an account. If you could download the source and show us the page for posting a topic, we might be able to help. I tried visiting the page just to see how the form was set up, but got what I can only assume was a message that I need to be logged in.

Share this post


Link to post
Share on other sites

Also show what messages are written to the SciTe console. Also, someone recently had two form controls on the same page with the same name and they were writing to the wrong one. Beware.

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

Share this post


Link to post
Share on other sites

We can't test it very well without an account. If you could download the source and show us the page for posting a topic, we might be able to help. I tried visiting the page just to see how the form was set up, but got what I can only assume was a message that I need to be logged in.

Thank you, and this is the web page I just saved.

Share this post


Link to post
Share on other sites

I opened your .htm file and ran the following code and it worked as expected:

#include <IE.au3>

$oIE = _IEAttach("Discuz", "text")

$oForm = _IEFormGetObjByName ($oIE, "postform")
$oText = _IEFormElementGetObjByName ($oForm, "title")
_IEFormElementSetValue ($oText, "testing titile")
   
$oText = _IEFormElementGetObjByName ($oForm, "message")
_IEFormElementSetValue ($oText, "testing message")

The _IEAction function call you chave in there is not valid because $oText is not an object, but rather the integer return value from the previous call.

The SciTe console messages would have made this much more obvious, but you ignored my request for those above. They are typically very instructive, please do not ignore them.

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

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  
Followers 0