Jump to content

Get reply as FormElement


Recommended Posts

Out of sudden i had this idea and i decided to make a UDF to go with it, just testing and see if it works.

But then the difficultity was to get the reply box as formelement(I am new to _IE), so i created this loop to do my job, but i have this error and i don't know why it's occuring.

ERROR: _IEFormElementGetValue() called with Const or expression on ByRef-param(s).
            If _IEFormElementGetValue(_IEFormElementGetCollection($oForm,$n))
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
E:\Program Files\AutoIt3\Include\IE.au3(1295,45) : REF: definition of _IEFormElementGetValue().

Here is the full script that i am working on, if anyone can help me solve this problem it would be great, as we can get the UDF to work and i can learn something about _IE.

Thanks in advance.

#include<IE.au3>
$thread="http://www.autoitscript.com/forum/index.php?showtopic=34748"
$Msg="Text"

_ForumReply($thread,$Msg)

Func _ForumReply($ThreadLink,$ReplyText)
    Local $oIE,$oForm,$oQuery
    $oIE=_IECreate($ThreadLink,0,1,0)
    Do
        Sleep(1)
    Until Not _IEPropertyGet($oIE, "busy")
    _IEImgClick($oIE,"http://www.autoitscript.com/forum/style_images/autoit/t_reply.gif","src",0,0)
    Do
        Sleep(1)
    Until Not _IEPropertyGet($oIE, "busy")
    MsgBox(64,"Warning","Input text into element and click ok to continue")
    $oForm = _IEFormGetCollection ($oIE)
    $iNumForm=@extended
    For $i=0 to $iNumForm-1
        $oForm = _IEFormGetCollection ($oIE, $i)
        $oQuery = _IEFormElementGetCollection ($oForm)
        $iNumElement=@extended
        For $n=0 to $iNumElement-1
            If _IEFormElementGetValue(_IEFormElementGetCollection($oForm,$n))="Text" Then
                MsgBox(64,"Form: "&$i,"Element: "&$ii)
            EndIf
        Next
    Next
EndFunc
Link to comment
Share on other sites

New problem...Any idea why it won't return the correct collection instance from the loop?

#include<IE.au3>
$thread="http://www.autoitscript.com/forum/index.php?showtopic=34748"
$Msg="Text"

_ForumReply($thread,$Msg)

Func _ForumReply($ThreadLink,$ReplyText)
    Local $oIE,$oForm,$oQuery,$o_Query
    $oIE=_IECreate($ThreadLink,0,1,0)
    Do
        Sleep(1)
    Until Not _IEPropertyGet($oIE, "busy")
    _IEImgClick($oIE,"http://www.autoitscript.com/forum/style_images/autoit/t_reply.gif","src",0,0)
    Do
        Sleep(1)
    Until Not _IEPropertyGet($oIE, "busy")
    MsgBox(64,"Warning","Input text into element and click ok to continue")
    $oForm = _IEFormGetCollection ($oIE)
    $iNumForm=@extended
    For $i=0 to $iNumForm-1
        $oForm = _IEFormGetCollection ($oIE, $i)
        $oQuery = _IEFormElementGetCollection ($oForm)
        $iNumElement=@extended
        For $n=0 to $iNumElement-1
            $o_Query=_IEFormElementGetCollection($oForm,$n)
            If _IEFormElementGetValue($o_Query)="Text" Then
                MsgBox(64,"Form: "&$i,"Element: "&$n)
            EndIf
        Next
    Next
EndFunc
Link to comment
Share on other sites

You cannot nest IE functions (actually, you cannot pass variable content as the object parameter since it is passed byRef)

You have not explained what you are trying to do well enough to understand your second question.

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 cannot nest IE functions (actually, you cannot pass variable content as the object parameter since it is passed byRef)

You have not explained what you are trying to do well enough to understand your second question.

Dale

This is an UDF that i am working on, basically it goes to the topic in AutoIt forum by a link you given, and the msg you want to reply, then it auto replys the topic by that and then submit the reply.

I was trying to get the obj index of the reply box, but many trys failed, so i came up with this, if anyone is willing to help it will be wonderful.

Link to comment
Share on other sites

This should help:

If String(_IEFormElementGetValue($o_Query))="Text" Then

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

This should help:

If String(_IEFormElementGetValue($o_Query))="Text" Then

Dale

The reason this is important is the following:

If any of the $o_Query fields you are testing the value for turn out to be empty (the .value property returns Null), your return value is actually a numeric 0 instead of an empty string. Your comparison turns out to be

If 0 = "Text" Then

AutoIt decides you are doing a numeric comparison and turns this into

If 0 = 0 Then

which, as you can see will always be True. The String function on the left side of the '=' forces a string comparison and produces the results you want.

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 reason this is important is the following:

If any of the $o_Query fields you are testing the value for turn out to be empty (the .value property returns Null), your return value is actually a numeric 0 instead of an empty string. Your comparison turns out to be

If 0 = "Text" Then

AutoIt decides you are doing a numeric comparison and turns this into

If 0 = 0 Then

which, as you can see will always be True. The String function on the left side of the '=' forces a string comparison and produces the results you want.

Dale

Big thanks, it worked.
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...