Jump to content

Check a sequence of pixels


Recommended Posts

The image is in a GUI or in a file?

case GUI

PixelGetColor() function will do the job

case File

What format is the file

case BMP

Theres a BMP library somewhere in the forum that is very simply and use only AutoIt native Functions

case else

You will need some GDI+ functions for that but again this was already done somewhere in the forum

Return "done"

Link to comment
Share on other sites

  • Moderators

StiveMox,

Search for the first colour. If found, search for the second. If found, search for the third. And so on.....

If any colour is not found, you do not have a valid image. :mellow:

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

  • Moderators

StiveMox,

So does it work?

What kind of question is that? Have you tried it yourself? :mellow:

And next time you want to post code, just put [autoit] before and [/autoit] after the code so it appears in a nice box here on the forum. :)

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

I was unaware of the code tags to place on the forum. Sorry.Yes I'm trying to do, but I'm beginner and I need help.

if PixelSearch($left, $top, $right, $bottom, $color1) and PixelSearch($left, $top, $right, $bottom, $color2) and PixelSearch($left, $top, $right, $bottom, $color1) Then
            MsgBox(0, "Validation", "Image valid!")
        EndIf

Edited by StiveMox
Link to comment
Share on other sites

I recomend to Post the entire script, because that fragment never will works beacuse the variables $left, $right, etc never were defined in the script.

Look in the help file the explain of the function and see the example to look how it work..

another function that you can use is PixelGetColor()

If you want to use PixelSearch then you have to define the parameters of the box where the function have to search for.

Link to comment
Share on other sites

  • Moderators

StiveMox,

That will not work because PixelSearch returns an array (look in the Help file for more details). I would do something like this untested):

; The return will be the result of the test
$fResult = _TestImage($left, $top, $right, $bottom, $color1, $color2, $color3)

Func _TestImage($left, $top, $right, $bottom, $color1, $color2, $color3)
    ; Look for first colour
    PixelSearch($left, $top, $right, $bottom, $color1)
    ; If not found then return false
    If @error Then Return False
    ; Look for second colour
    PixelSearch($left, $top, $right, $bottom, $color2)
    If @error Then Return False
    ; Look for third colour
    PixelSearch($left, $top, $right, $bottom, $color3)
    If @error Then Return False
    ; We must have found all 3 so return true
    Return True
EndFunc

Try that and see how you get on. :mellow:

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

;Check if the image exists some colors required.

While 1
    Sleep(1)
WEnd

HotKeySet("{q}", "start") ;start the image verification
HotKeySet("{w}", "stop") ;close the soft

Func start()

    Dim $coord[4] = [306, 357, 677, 535]
    Dim $colors[3] = [0xff0f0f, 0xff860f, 0x601b5c]

    While 2
    
        If PixelSearch($coord[0], $coord[1], $coord[2], $coord[3], $colors[0]) and PixelSearch($coord[0], $coord[1], $coord[2], $coord[3], $colors[1]) Then
        MsgBox(0, "Image verification", "The image is valid!")
        EndIf
    WEnd
EndFunc

Func stop()
    Exit
EndFunc

@Melba23

I will try. Thanks.

Edited by StiveMox
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...