Jump to content

Pixel Search


dwedwe
 Share

Recommended Posts

Sir/Ma'am,

I am new to autoit so please bear with me, i need help with this please see attached file, many thanks to all.

$color1 = 0xED1C24 ;red
$color2 = 0xFFFFFF ;white
$color3 = 0x22B14C ;green
$color4 = 0x00A2E8 ;blue

;lets say (999,366,1331,566) is the yellow outer square

$Scan_Area = PixelSearch(999,366,1331,566,$color1)

;how do i delete the BOX2 & BOX1 but not delete BOX3?

while(1)
    if IsArray($Scan_Area) = ???? then
        Mousemove($Scan_Area[0],$Scan_Area[1],10)
        Mouseclick($Scan_Area[0],$Scan_Area[1],1,10)
        Send("{delete}")
        Sleep(500)
    Endif
Wend

search box.jpg

Edited by dwedwe
Link to comment
Share on other sites

  • Moderators

dwedwe,

Something like this ought to do the trick:

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

#include <Color.au3>

Opt("PixelCoordMode", 2)
Opt("MouseCoordMode", 2)

$iSearchColour = 0xC12B30 ; Red - adjusted to match actual value in saved image

$hGUI = GUICreate("Test", 500, 500)

GUICtrlCreatePic("Box.jpg", 10, 10, 250, 250)

GUISetState()

; Set search area start
$iY = 10
; And instance counter
$iCount = 1

While 1
    
    ; look for the red center diamond
    $aRet = PixelSearch(10, $iY, 260, 260, $iSearchColour, 50)
    If @error Then
        ConsoleWrite("No Diamonds Found" & @CRLF)
    Else
        ; Move mouse to the diamond
        MouseMove($aRet[0], $aRet[1])

        ; Get the colour of the pixel 10 pixels up and left of the red diamond
        $iCol = PixelGetColor($aRet[0] - 10, $aRet[1] - 10)
        ConsoleWrite(Hex($iCol) & @CRLF)

        ; Check for high blue and low red content at that pixel
        If _ColorGetBlue($iCol) > 128 And _ColorGetRed($iCol) < 128 Then
            ; Do not delete
            MsgBox($MB_SYSTEMMODAL, "", "Not Deleting")
        Else
            ; Delete
            MsgBox($MB_SYSTEMMODAL, "", "Deleting")
        EndIf

        ; Reset the start position to search for the next red diamond
        $iY = $aRet[1] + 10
        ; Stop once we have them all
        $iCount += 1
        If $iCount = 4 Then ExitLoop
        
    EndIf

WEnd

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
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
 Share

×
×
  • Create New...