litlmike Posted June 25, 2008 Share Posted June 25, 2008 (edited) I have an object: $oDiv And I have an array, which contains the 'scope' (property) names of the object, like ID, className, innerText: $aDivProperties I would like to reference the object's properties using these variables, how would I do that? For example, I would normally make these types of references: $oDiv.ClassName $oDiv.InnerText $oDiv.ID Instead I would like to call it from an Array element like: $oDiv.$aDivProperties[$iCount] But, this gives a syntax error, so how do I get around this? Thanks Local $aDivProperties [78]= ['ariaBusy','ariaChecked','ariaDisabled','ariaExpanded','ariaHaspopup', _ 'ariaHidden','ariaInvalid','ariaLevel','ariaMultiselect','ariaPosinset', _ 'ariaPressed','ariaReadonly','ariaRequired','ariaSecret','ariaSelected', _ 'ariaSetsize','attributes','blockDirection','canHaveChildren','canHaveHTML', _ 'className','clientHeight','clientLeft','clientTop','clientWidth', _ 'contentEditable','counterIncrement','counterReset','dataFld','dataFormatAs', _ 'dataSrc','dir','disabled','firstChild','hideFocus', _ 'id','innerHTML','innerText','isContentEditable','isDisabled', _ 'isMultiLine','isTextEdit','lang','language','lastChild', _ 'msBoxSizing','nextSibling','nodeName','nodeType','nodeValue', _ 'noWrap','offsetHeight','offsetLeft','offsetParent','offsetTop', _ 'offsetWidth','onOffBehavior','outerHTML','outerText','ownerDocument', _ 'parentElement','parentNode','parentTextEdit','previousSibling','readyState', _ 'recordNumber','role','scopeName','scrollHeight','scrollLeft', _ 'scrollTop','scrollWidth','sourceIndex','tabIndex','tagName', _ 'tagUrn','title','uniqueID'] $oDivs = _IETagNameGetCollection ($oIE, "div") $iCount=0 For $oDiv In $oDivs ConsoleWrite ($oDiv.$aDivProperties[$iCount] & @CRLF) $iCount+=1 Next Edited June 25, 2008 by litlmike _ArrayPermute()_ArrayUnique()Excel.au3 UDF Link to comment Share on other sites More sharing options...
litlmike Posted June 25, 2008 Author Share Posted June 25, 2008 Hmmm... even this didn't work: ConsoleWrite (Eval("aDivProperties") & "." & String($aDivProperties[$iCount]) & @CRLF) _ArrayPermute()_ArrayUnique()Excel.au3 UDF Link to comment Share on other sites More sharing options...
ptrex Posted June 25, 2008 Share Posted June 25, 2008 @litlmike I 'm sure I 've seen that question before a few years back ?! But I can't tell if it was ever resolved, sorry. Regards, ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
litlmike Posted June 25, 2008 Author Share Posted June 25, 2008 @litlmikeI 'm sure I 've seen that question before a few years back ?!But I can't tell if it was ever resolved, sorry.Regards,ptrexDarn! I was thinking to myself, "oh, this is just one of those syntax issues that I don't understand because I am still just a wanna-be coder." Man, I thought this was going to be a quick solution! Thanks for the reply. _ArrayPermute()_ArrayUnique()Excel.au3 UDF Link to comment Share on other sites More sharing options...
weaponx Posted June 25, 2008 Share Posted June 25, 2008 In ActionScript and Javascript you can access objects multiple ways: document.formName.fieldName.value document.formName["fieldName"].value document["formName"]["fieldName"].value document.formName[variableName].value Link to comment Share on other sites More sharing options...
litlmike Posted June 25, 2008 Author Share Posted June 25, 2008 (edited) In ActionScript and Javascript you can access objects multiple ways: document.formName.fieldName.value document.formName["fieldName"].value document["formName"]["fieldName"].value document.formName[variableName].valueSo are you implying that this cannot be done in AutoIt? ConsoleWrite ($oLink.uniqueID & @CRLF);Example of what I want to say Here are some attempts, based upon that direction, but they still seem to fail: Local $aLinkProperties [49]= ['ariaChecked','ariaDisabled','ariaExpanded','ariaHaspopup','ariaHidden', _ 'ariaInvalid','ariaLevel','ariaMultiselect','ariaPosinset','ariaPressed', _ 'ariaReadonly','ariaRequired','ariaSecret','ariaSelected','ariaSetsize', _ 'attributes','canHaveHTML','charset','disabled','firstChild', _ 'href','hreflang','id','isContentEditable','isDisabled', _ 'isMultiLine','isTextEdit','lastChild','name','nextSibling', _ 'nodeName','nodeType','nodeValue','ownerDocument','parentElement', _ 'parentNode','parentTextEdit','previousSibling','readyState','rel', _ 'rev','role','scopeName','sourceIndex','tagName', _ 'tagUrn','target','type','uniqueID'] $oIE = _IECreate ("www.Google.com", 1, 1, 1, 0) $oLinks = _IELinkGetCollection ($oIE) $iCount=0 For $oLink In $oLinks ConsoleWrite ($oLink.uniqueID & @CRLF) ;Example of what I want to say ConsoleWrite ($oLink.$aLinkProperties[$iCount] & @CRLF) ;This is what I want to say ConsoleWrite ($oLink.$aLinkProperties[$iCount] & @CRLF) ;Another Attempt ConsoleWrite ($oLink["aDivProperties"].$iCount & @CRLF) ;Another Attempt ConsoleWrite ($oLink["aDivProperties"]["$iCount"] & @CRLF) ;Another Attempt ConsoleWrite ($oLink[$aLinkProperties][$iCount] & @CRLF) ;Another Attempt ConsoleWrite ($oLink[$aLinkProperties].$iCount & @CRLF) ;Another Attempt $iCount+=1 Next Edited June 25, 2008 by litlmike _ArrayPermute()_ArrayUnique()Excel.au3 UDF Link to comment Share on other sites More sharing options...
zorphnog Posted June 25, 2008 Share Posted June 25, 2008 Perhaps this is what you are trying to do? #include <IE.au3> Local $aLinkProperties [49]= ['ariaChecked','ariaDisabled','ariaExpanded','ariaHaspopup','ariaHidden', _ 'ariaInvalid','ariaLevel','ariaMultiselect','ariaPosinset','ariaPressed', _ 'ariaReadonly','ariaRequired','ariaSecret','ariaSelected','ariaSetsize', _ 'attributes','canHaveHTML','charset','disabled','firstChild', _ 'href','hreflang','id','isContentEditable','isDisabled', _ 'isMultiLine','isTextEdit','lastChild','name','nextSibling', _ 'nodeName','nodeType','nodeValue','ownerDocument','parentElement', _ 'parentNode','parentTextEdit','previousSibling','readyState','rel', _ 'rev','role','scopeName','sourceIndex','tagName', _ 'tagUrn','target','type','uniqueID'] $oIE = _IECreate ("www.Google.com", 1, 1, 1, 0) $oLinks = _IELinkGetCollection ($oIE) $iCount=0 For $oLink In $oLinks ConsoleWrite ($oLink.uniqueID & @CRLF) ;Example of what I want to say For $i=0 To 48 Execute("ConsoleWrite(@TAB & '" & $aLinkProperties[$i] & ":' & $oLink." & $aLinkProperties[$i] & " & @CRLF)") ;Another Attempt Next Next Link to comment Share on other sites More sharing options...
weaponx Posted June 25, 2008 Share Posted June 25, 2008 (edited) First off I would like to say...who's your daddy? Second, most of the attributes in your array won't apply to the $oLink object. Here is a list of the available properties for an AnchorElement object:http://msdn.microsoft.com/en-us/library/bb149161.aspx#include <IE.au3> $oIE = _IECreate ("www.Google.com", 1, 1, 1, 0) ConsoleWrite(ObjName($oIE) & @CRLF) $oLinks = _IELinkGetCollection ($oIE) ConsoleWrite(ObjName($oLinks) & @CRLF) $iCount=0 For $oLink In $oLinks ConsoleWrite($oLink.getAttribute("uniqueID") & @CRLF) ConsoleWrite ($oLink.uniqueID & @CRLF) ;Example of what I want to say $iCount+=1 Next Edited June 25, 2008 by weaponx Link to comment Share on other sites More sharing options...
litlmike Posted June 25, 2008 Author Share Posted June 25, 2008 Perhaps this is what you are trying to do?First off I would like to say...who's your daddy? Second, most of the attributes in your array won't apply to the $oLink object. Here is a list of the available properties for an AnchorElement object:http://msdn.microsoft.com/en-us/library/bb149161.aspxWow! Nice from both of you! Thanks, I learned the following:1) Who my real daddy is2) That getAttribute exits3) That @TAB exists4) Execute has some usefulness5) Some ActionScript and Javascript syntax6) That there is always a solution to life's problems with AutoIt@weaponx:What is the difference between your link (1st one below) and this link (2nd one)? The second one is where I was going for the MSDN info.http://msdn.microsoft.com/en-us/library/bb149161.aspxhttp://msdn.microsoft.com/en-us/library/ms535173(VS.85).aspx _ArrayPermute()_ArrayUnique()Excel.au3 UDF Link to comment Share on other sites More sharing options...
litlmike Posted June 25, 2008 Author Share Posted June 25, 2008 Oops, I forgot to post this: Local $aLinkProperties [49]= ['ariaChecked','ariaDisabled','ariaExpanded','ariaHaspopup','ariaHidden', _ 'ariaInvalid','ariaLevel','ariaMultiselect','ariaPosinset','ariaPressed', _ 'ariaReadonly','ariaRequired','ariaSecret','ariaSelected','ariaSetsize', _ 'attributes','canHaveHTML','charset','disabled','firstChild', _ 'href','hreflang','id','isContentEditable','isDisabled', _ 'isMultiLine','isTextEdit','lastChild','name','nextSibling', _ 'nodeName','nodeType','nodeValue','ownerDocument','parentElement', _ 'parentNode','parentTextEdit','previousSibling','readyState','rel', _ 'rev','role','scopeName','sourceIndex','tagName', _ 'tagUrn','target','type','uniqueID'] $oIE = _IECreate ("www.Google.com", 1, 1, 1, 0) $oLinks = _IELinkGetCollection ($oIE) $iCount=0 For $oLink In $oLinks ConsoleWrite ("$oLink.href = " & $oLink.href & @CRLF) ;The link For $iCC=0 To UBound($aLinkProperties)-1 ConsoleWrite(@TAB & $aLinkProperties[$iCC] & ":" & $oLink.getAttribute($aLinkProperties[$iCC]) & @CRLF) ;The link properties Next ConsoleWrite (@CRLF) Next _ArrayPermute()_ArrayUnique()Excel.au3 UDF Link to comment Share on other sites More sharing options...
weaponx Posted June 26, 2008 Share Posted June 26, 2008 @weaponx:What is the difference between your link (1st one below) and this link (2nd one)? The second one is where I was going for the MSDN info.http://msdn.microsoft.com/en-us/library/bb149161.aspxhttp://msdn.microsoft.com/en-us/library/ms535173(VS.85).aspxThe link you posted is a reference to the object formatting in raw html. The link I posted is what the html objects are parsed into by DOM. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now