Function Reference


ObjName

Returns the name or interface description of an Object.

ObjName ( $Objectvariable [, Flag = 1] )

Parameters

$Objectvariable A variable containing an Object whose name you want to retrieve
Flag [optional]
    $OBJ_NAME (1) = (default) The name of the Object
    $OBJ_STRING (2) = Description string of the Object
    $OBJ_PROGID (3) = The ProgID of the Object
    $OBJ_FILE (4) = The file that is associated with the object in the Registry
    $OBJ_MODULE (5) = Module name in which the object runs (WIN XP And above). Marshaller for non-inproc objects.
    $OBJ_CLSID (6) = CLSID of the object's coclass
    $OBJ_IID (7) = IID of the object's interface

Constants are defined in "AutoItConstants.au3".

Return Value

Success: a string representing the name
Failure: "" (empty string) and sets the @error flag to non-zero.

Remarks

Not all Objects support flags 2 to 7. Always test for @error in these cases.

Related

IsObj, ObjCreate, ObjGet

Example

Example 1

#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>

Local $oInternet = ObjCreate("InternetExplorer.Application")
$oInternet.Navigate("http://www.google.com") ; Opening a web page that contains a form
Sleep(4000) ; Give the page time to load

Local $oDoc = $oInternet.Document ; Example object to test
Local $oForm = $oDoc.Forms(0) ; Example object to test

MsgBox($MB_SYSTEMMODAL, "", "Interface name of $oInternet is: " & ObjName($oInternet) & @CRLF & _
                "Object name of $oInternet is:    " & ObjName($oInternet, $OBJ_STRING) & @CRLF & _
                "Interface name of $oDoc is:      " & ObjName($oDoc) & @CRLF & _
                "Object name of $oDoc is:         " & ObjName($oDoc, $OBJ_STRING) & @CRLF & _
                "Interface name of $oForm is:     " & ObjName($oForm) & @CRLF & _
                "Object name of $oForm is:        " & ObjName($oForm, $OBJ_STRING))
$oInternet.Quit()

Example 2

#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>

Local $oObj = ObjCreate("InternetExplorer.Application")
ObjName_FlagsValue($oObj)

Func ObjName_FlagsValue(ByRef $oObj)
        Local $sInfo = ''

        $sInfo &= '+>' & @TAB & 'ObjName($oObj,1) {The name of the Object} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_NAME) & @CRLF

        ; HELPFILE REMARKS: Not all Objects support flags 2 to 7. Always test for @error in these cases.
        $sInfo &= '+>' & @TAB & 'ObjName($oObj,2) {Description string of the Object} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_STRING)
        If @error Then $sInfo &= '@error = ' & @error
        $sInfo &= @CRLF & @CRLF

        $sInfo &= '+>' & @TAB & 'ObjName($oObj,3) {The ProgID of the Object} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_PROGID)
        If @error Then $sInfo &= '@error = ' & @error
        $sInfo &= @CRLF & @CRLF

        $sInfo &= '+>' & @TAB & 'ObjName($oObj,4) {The file that is associated with the object in the Registry} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_FILE)
        If @error Then $sInfo &= '@error = ' & @error
        $sInfo &= @CRLF & @CRLF

        $sInfo &= '+>' & @TAB & 'ObjName($oObj,5) {Module name in which the object runs (WIN XP And above). Marshaller for non-inproc objects.} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_MODULE)
        If @error Then $sInfo &= '@error = ' & @error
        $sInfo &= @CRLF & @CRLF

        $sInfo &= '+>' & @TAB & 'ObjName($oObj,6) {CLSID of the object''s coclass} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_CLSID)
        If @error Then $sInfo &= '@error = ' & @error
        $sInfo &= @CRLF & @CRLF

        $sInfo &= '+>' & @TAB & 'ObjName($oObj,7) {IID of the object''s interface} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_IID)
        If @error Then $sInfo &= '@error = ' & @error
        $sInfo &= @CRLF & @CRLF

        MsgBox($MB_SYSTEMMODAL, "ObjName:", $sInfo)
EndFunc   ;==>ObjName_FlagsValue