Jump to content

Recommended Posts

Posted

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

Posted

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

Posted

I have used successfully it in some situations.

Seems like it doesnt work with _IEGetObjByName????

Am I using it incorrectly?

Is there a better way to evaluate the return val of the function?

Posted

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 ""

Posted

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')
Posted

- 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

Posted

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
Posted

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

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
×
×
  • Create New...