Jump to content

Search the Community

Showing results for tags 'classname'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. So in my time of coding I found a better, precise and more powerful way of finding element objects by classname and by tags. Its called querySelectorAll and it looks like this. Now I can forget needing to use a combination of _ietagnameget... and _iegetobjbyclassname... and just use one function. I have not tested this on the latest version of autoit, due to the many script braking changes, but I think it should still work. Credit to Dale Hohm who built the foundation of IE UDF and mLipok who made the error checking better on a previous post. DO note: This a relatively recent add-on to IE so it requires IE 9 and above. If you find you receive a com error of "unknown name" its likely the site is using meta tag attribute X-UA-Compatible which has reverted the browser to forget about it. Comments welcome ;#FUNCTION#============================================================================================================= ; Name...........: _IEquerySelectorAll() ; Description ...: Returns an Object or a Colection of objects ; Syntax.........: (ByRef $oDoc, $sQuery, $iItemIndex = Default) ; Parameters ....: $oDoc - The document object from IE ; $sQuery - String of Query. Example: _IEquerySelectorAll($oDoc, '"div.note, div.alert"', Default) will return a colection of div elements with classes of note and alert ; $iItemIndex - [optional] Default returns a colection, else use a 0 based index to indicate the object in sequence ; Return values .: Success - Object or a Colection of objects ; Failure - returns 0 sets the @error flag to non-zero. ; 3 ($_IEStatus_InvalidDataType) - Invalid Data Type ; 4 ($_IEStatus_InvalidObjectType) - Invalid Object Type ; 5 ($_IEStatus_InvalidValue) - Invalid Value ; 7 ($_IEStatus_NoMatch) - No Match ; Author ........: XThrax aka uncommon ; Remarks .......: This fuction was pretty much stolen from Dale Hohm the IE UDF creator so much credit to him, also to mLipok who made the error checking better. ; Also note that this a relatively recent add-on to IE so it requires IE 9 and above. ; If you find you receive a com error of "unknown name" its likely the site is using meta tag attribute X-UA-Compatible which has reverted the browser to forget about it. ; ; Related .......: _IETagNameAllGetCollection();_IEClassNameGetCollection() ; Link ..........;https://www.autoitscript.com/forum/topic/181376-_iequeryselectorall/ ; https://msdn.microsoft.com/en-us/library/cc304115(v=vs.85).aspx ; Example .......; No ; ===================================================================================================================== Func _IEquerySelectorAll(ByRef $oDoc, $sQuery, $iItemIndex = Default) If Not IsObj($oDoc) Then ConsoleWriteError("--> _IEquerySelectorAll Error: " & $_IEStatus_InvalidDataType & " Invalid DataType" & @LF) Return SetError($_IEStatus_InvalidDataType, 1, 0) ElseIf Not __IEIsObjType($oDoc, "browserdom") Then ConsoleWriteError("--> _IEquerySelectorAll Error: " & $_IEStatus_InvalidObjectType & " Invalid ObjectType" & @LF) Return SetError($_IEStatus_InvalidObjectType, 2, 0) ElseIf Not IsNumber($iItemIndex) And $iItemIndex <> Default Then ConsoleWriteError("--> _IEquerySelectorAll Error: " & $_IEStatus_InvalidValue & " Invalid Index" & @LF) Return SetError($_IEStatus_InvalidValue, 3, 0) ElseIf $iItemIndex = Default Or $iItemIndex >= 0 Then Local $oTemp = Null If __IEIsObjType($oDoc, "documentcontainer") Then $oTemp = _IEDocGetObj($oDoc) ConsoleWriteError("--> _IEDocGetObj Error: " & @error & " Ext: " & @extended & @LF) If @error Then Return SetError(@error, @extended, 0) Else $oTemp = $oDoc EndIf Local $oClassColl = $oTemp.querySelectorAll($sQuery) If @error Then ConsoleWriteError("--> _IEquerySelectorAll Error: " & $_IESTATUS_GeneralError & " GeneralError1: " & @error & @LF) Return SetError($_IESTATUS_GeneralError, 3, 0) ElseIf (Not IsObj($oClassColl)) Or $oClassColl = Null Or $oClassColl.length = 0 Then ConsoleWriteError("--> _IEquerySelectorAll Error: " & $_IEStatus_NoMatch & " NoMatch" & @LF) Return SetError($_IEStatus_NoMatch, 0, 0) ; Could be caused by parameter 2, 3 or both Else If $iItemIndex = Default Then Return SetError($_IEStatus_Success, $oClassColl.length, $oClassColl) ElseIf $iItemIndex > $oClassColl.length Then ConsoleWriteError("--> _IEquerySelectorAll Error: " & $_IEStatus_InvalidValue & " Invalid Value" & @LF) Return SetError($_IEStatus_InvalidValue, $oClassColl.length, 0) Else $oItem = $oClassColl.Item($iItemIndex) If @error Then ConsoleWriteError("--> _IEquerySelectorAll Error: " & $_IESTATUS_GeneralError & " GeneralError2: " & @error & @LF) Return SetError($_IESTATUS_GeneralError, 3, 0) ElseIf (Not IsObj($oItem)) Or $oItem = Null Then ConsoleWriteError("--> _IEquerySelectorAll Error: " & $_IEStatus_NoMatch & " NoMatch Index: " & $iItemIndex & @LF) Return SetError($_IEStatus_NoMatch, 0, 0) ; Could be caused by parameter 2, 3 or both Else Return SetError($_IEStatus_Success, 0, $oItem) EndIf EndIf EndIf Else ConsoleWriteError("--> _IEquerySelectorAll Error: " & $_IEStatus_InvalidValue & " Invalid Value: " & $iItemIndex & @LF) Return SetError($_IEStatus_InvalidValue, 3, 0) EndIf EndFunc ;==>_IEquerySelectorAll
×
×
  • Create New...