Jump to content

_IEGetObjByName: evaluating return values


Recommended Posts

I am using this function: _IEGetObjByName

Using a MsgBox, I try to evaluate the return code.

The message box contains no message (there is no return value?).

What is returned on success and on failure?

The documentation says an object returned on success and 0 on failure. MsgBox seems to have neither.

My Code: trying to get a 'Export To Excel' button by name ***************

;button: <input type="submit" name="TriageResult1:btExport" value="Export to Excel" id="TriageResult1_btExport" />

$oIE = _IEAttach ($hWnd, "embedded")

$oSubmit = _IEGetObjByName($oIE, "TriageResult1:btExport")

MsgBox($oSubmit) ;dislays empty msg box

if ($oSubmit = 0) Then

HandleError("_IEGetObjByName- EXPORT TO EXCEL...", @error, $iTryLoop)

EndIf

Link to comment
Share on other sites

It returns an object. A msgbox is used to display a string, which is why nothing is being displayed.

Link to comment
Share on other sites

I will try to use "ObjName".

Other Options?

Returns the name or interface description of an Object

ObjName ( $Objectvariable [,Flag] )

Return Value

Success: Returns a string representing the name

Failure: Sets @error and Returns ""

Link to comment
Share on other sites

Yes. In your case you could use something like this to verify.

$oSubmit = _IEGetObjByName($oIE, "TriageResult1:btExport")
If $oSubmit = 0 then Msgbox(0,'','Error geting object')
Link to comment
Share on other sites

I have used successfully it in some situations.

I would dearly love to see an example of just one of those situations...

:mellow:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

- sorry, didnt mean "MsgBox($oSubmit)", meant MsgBox(0,"",$oSubmit)

- seems like IEGetObjByName returns 0 if fails, returns "DispHTMLInputElement" if success (getting button) and returns nothing if page hasnt loaded or something has gone wrong

Have been playing with it, this is what I will do now:

$oIE = _IEAttach ($hWnd, "embedded")

$oSubmit = _IEGetObjByName($oIE, "TriageResult1:btExport")

if (StringCompare(ObjName($oSubmit), "DispHTMLInputElement") <> 0) Then

HandleError("_IEGetObjByName- EXPORT TO EXCEL...", @error, $iTryLoop)

SendMail("autoit script fail: imedic download", $sAllErrorMsgs)

Exit

EndIf

Link to comment
Share on other sites

A little over done, since _IEGetObjByName() sets @error (see help file):

$oSubmit = _IEGetObjByName($oIE, "TriageResult1:btExport")
If @error Then
     ; Handle error
EndIf

:mellow:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I could concieve it working something like

MsgBox(0,"",$oSubmit)

I'd still like to see a working example of that! I don't think AutoIt has any method built in to cast any object as a string.

:mellow:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...