sammy1983

Unable to click on colored frame

6 posts in this topic

Hi Folks,

Can anyone assist me in identifying the colored rectangle and click on it?

<td class="tile" id="c_15" style="background-color: rgb(223, 223, 223);">YES</td>

I really don't know how to code it?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

; Most Basic Example

$aCoords = PixelSearch($x1, $y1, $x2, $y2, "#DFDFDF")
MouseClick("Primary", $aCoords[0], $aCoords[1])

 

Edited by rcmaehl

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

MY PROJECTS


Active: IRC UDF
Discontinued: GithubBubbleSort UDF

Share this post


Link to post
Share on other sites
20 minutes ago, rcmaehl said:
; Most Basic Example

$aCoords = PixelSearch($x1, $y1, $x2, $y2, "#DFDFDF")
MouseClick("Primary", $aCoords[0], $aCoords[1])

 

Thanks but what is $x1, $y1, $x2, $y2?

Share this post


Link to post
Share on other sites
2 minutes ago, sammy1983 said:

Thanks but what is $x1, $y1, $x2, $y2?

Here's the Helpfile for PixelSearch. It explains it better than I can:

https://www.autoitscript.com/autoit3/docs/functions/PixelSearch.htm


My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

MY PROJECTS


Active: IRC UDF
Discontinued: GithubBubbleSort UDF

Share this post


Link to post
Share on other sites
20 hours ago, rcmaehl said:

Here's the Helpfile for PixelSearch. It explains it better than I can:

https://www.autoitscript.com/autoit3/docs/functions/PixelSearch.htm

Thanks rcmaehl.. I tried this and it worked. :)

Local $sHTML = _IEDocReadHTML($oIE1)
$array = StringRegExp($sHTML, '(?i)style="background-color: (.*?);">YES', 3)
For $i = 0 To UBound($array) - 1
    $test = $array[$i]
    If $test = "rgb(223, 223, 223)" then        
        Local $Color = _IEGetObjById($oIE1, "c_" & $j)
        _IEAction($Color, "click")
        Exit
    EndIf
Next

 

Share this post


Link to post
Share on other sites

Just try this:

;~ https://www.autoitscript.com/forum/topic/184447-unable-to-click-on-colored-frame
.......
.......
.......
_Example($oIE)
.......
.......
.......

Func _Example(ByRef $oIE)
    ; <td class="tile" id="c_15" style="background-color: rgb(223, 223, 223);">YES</td>

    ; https://www.w3.org/TR/css3-selectors/#selectors
    ; find TD tag with attribute style="background-color: rgb(223, 223, 223);"
    Local $oSelection = _IEquerySelectorAll($oIE, 'td[style="background-color: rgb(223, 223, 223);"]', 0)
    If Not @error Then _IEAction($oSelection, 'click')
EndFunc   ;==>_Example




;#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)
            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


 


>>>> Directory Enquiries Challenge <<<<
NEW:     ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button:

Spoiler

Last update: 2016-08-11
Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft Components * TeamViewer API -UDF * JavaManagement UDF * VIES over SOAPPOP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF * WinSCP UDF *

My contribution to others projects: * _sql.au3 UDF  *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, The Art of Computer Programming
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

 

Share this post


Link to post
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