Jump to content

How about PixelParten or PixelMatrix or PixelArray or StringPixex


Recommended Posts

I seen a function on the internet somewhere the other day, which would seem to fit your needs, I'll try to find it again.

EDIT: Actually it was pixelchecksumsearch.

http://autoitcoding.boards.net/thread/10/search-screen-pixel-checksum

You could alter it to fit your needs, or just get a checksum of red green yellow and pass that to it.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

1 hour ago, JohnOne said:

I seen a function on the internet somewhere the other day, which would seem to fit your needs, I'll try to find it again.

I need a sample of code. if you can find I'll thank you.

 

Link to comment
Share on other sites

Start at help file.

Opt("PixelCoordMode", 1)
HotKeySet("{Esc}", "_Exit")


$__x = 43
$__y = 156
$__width = 10
$__height = 10
Sleep(3000)

$col = PixelGetColor($__x, $__y) ;Get top left color or checksum area
$sum = PixelChecksum($__x, $__y, $__x + $__width, $__y + $__height) ; Get checksum of area

$timer = TimerInit()
_PictureSearch($col, $sum)
$time = TimerDiff($timer)
ConsoleWrite($time & @LF)



Func _PictureSearch($Color, $Checksum)
    $iX = @DesktopWidth
    $iY = @DesktopHeight
    $myY = 0
    Do
        $aPos = PixelSearch(0, $myY, $iX, $iY, $Color)
        If IsArray($aPos) Then
            If PixelChecksum($aPos[0], $aPos[1], $aPos[0] + 10, $aPos[1] + 10) = $Checksum Then
                MouseMove($aPos[0], $aPos[1], 0)
                Sleep(1000) ; Just to show it working
            EndIf
            _SearchX($aPos[0], $aPos[1])
            $myY = $aPos[1] + 1
        Else
            $myY = @DesktopHeight
        EndIf
    Until $myY >= @DesktopHeight
EndFunc   ;==>_PictureSearch

Func _SearchX($X, $Y)
    Local $a
    Do
        $a = PixelSearch($X + 1, $Y, @DesktopWidth, $Y, $col)
        If IsArray($a) Then
            $X = $a[0]
            If PixelChecksum($a[0], $a[1], $a[0] + 10, $a[1] + 10) = $sum Then
                MouseMove($a[0], $a[1], 0)
            EndIf
        Else
            $X = @DesktopWidth
        EndIf
    Until $X >= @DesktopWidth

EndFunc   ;==>_SearchX

Func _Exit()
    Exit
EndFunc   ;==>_Exit

 

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

1 hour ago, JohnOne said:

Start at help file.

Opt("PixelCoordMode", 1)
HotKeySet("{Esc}", "_Exit")


$__x = 43
$__y = 156
$__width = 10
$__height = 10
Sleep(3000)

$col = PixelGetColor($__x, $__y) ;Get top left color or checksum area
$sum = PixelChecksum($__x, $__y, $__x + $__width, $__y + $__height) ; Get checksum of area

$timer = TimerInit()
_PictureSearch($col, $sum)
$time = TimerDiff($timer)
ConsoleWrite($time & @LF)



Func _PictureSearch($Color, $Checksum)
    $iX = @DesktopWidth
    $iY = @DesktopHeight
    $myY = 0
    Do
        $aPos = PixelSearch(0, $myY, $iX, $iY, $Color)
        If IsArray($aPos) Then
            If PixelChecksum($aPos[0], $aPos[1], $aPos[0] + 10, $aPos[1] + 10) = $Checksum Then
                MouseMove($aPos[0], $aPos[1], 0)
                Sleep(1000) ; Just to show it working
            EndIf
            _SearchX($aPos[0], $aPos[1])
            $myY = $aPos[1] + 1
        Else
            $myY = @DesktopHeight
        EndIf
    Until $myY >= @DesktopHeight
EndFunc   ;==>_PictureSearch

Func _SearchX($X, $Y)
    Local $a
    Do
        $a = PixelSearch($X + 1, $Y, @DesktopWidth, $Y, $col)
        If IsArray($a) Then
            $X = $a[0]
            If PixelChecksum($a[0], $a[1], $a[0] + 10, $a[1] + 10) = $sum Then
                MouseMove($a[0], $a[1], 0)
            EndIf
        Else
            $X = @DesktopWidth
        EndIf
    Until $X >= @DesktopWidth

EndFunc   ;==>_SearchX

Func _Exit()
    Exit
EndFunc   ;==>_Exit

 

Don't know how it can be useful to meCan you explain in more detail ?

Link to comment
Share on other sites

1 hour ago, Masheen said:

Don't know how it can be useful to meCan you explain in more detail ?

Sounds more like "Can you write this for me because I don't want to learn how to do it for myself."

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

1 hour ago, BrewManNH said:

Sounds more like "Can you write this for me because I don't want to learn how to do it for myself."

no it is not true. Maybe other solution will be usefull and understandble for me

Link to comment
Share on other sites

Before we go further - this isn't for a game is it? If it is, then understand that is against forum rules. If it isn't, then there is many better ways to hook into controls than to use pixel search. You have pictures of what you want to look for but the links are broken. 

Also, you make want to look here on learning to code in AutoIt. This will really help you in understanding what we are telling you. 

 

 

Link to comment
Share on other sites

If you have scite in full screen, and run this code from it, it should find the scite icon.

if there were 20 scite icons it would find them all.

You can figure out how to adapt it to your needs, and if you cannot, you are not ready to even try to write the code you want to.

I took replaced some magic numbers from original linked code.

Opt("PixelCoordMode", 1)
HotKeySet("{Esc}", "_Exit")

;Sleep(3000)
; Here you define the screen position of a known image
;  The image can be 1x1 pixels if you like
$__x = 10
$__y = 10
$__width = 10
$__height = 10
Sleep(3000)

; This part of code is getting the top left pixel color
;  and the checksum of the above defined area
$col = PixelGetColor($__x, $__y) ;Get top left color of checksum area
$sum = PixelChecksum($__x, $__y, $__x + $__width, $__y + $__height) ; Get checksum of area

; Here is the simple example
$timer = TimerInit()
_PictureSearch($col, $sum)
$time = TimerDiff($timer)
ConsoleWrite($time & @LF)



Func _PictureSearch($Color, $Checksum)
    $iX = @DesktopWidth
    $iY = @DesktopHeight
    $myY = 0
    Do
        $aPos = PixelSearch(0, $myY, $iX, $iY, $Color)
        If IsArray($aPos) Then
            If PixelChecksum($aPos[0], $aPos[1], $aPos[0] + $__width, $aPos[1] + $__height) = $Checksum Then
                MouseMove($aPos[0], $aPos[1], 0)
                Sleep(1000) ; Just to show it working
            EndIf
            _SearchX($aPos[0], $aPos[1])
            $myY = $aPos[1] + 1
        Else
            $myY = @DesktopHeight
        EndIf
    Until $myY >= @DesktopHeight
EndFunc   ;==>_PictureSearch

Func _SearchX($X, $Y)
    Local $a
    Do
        $a = PixelSearch($X + 1, $Y, @DesktopWidth, $Y, $col)
        If IsArray($a) Then
            $X = $a[0]
            If PixelChecksum($a[0], $a[1], $a[0] + $__width, $a[1] + $__height) = $sum Then
                MouseMove($a[0], $a[1], 0)
            EndIf
        Else
            $X = @DesktopWidth
        EndIf
    Until $X >= @DesktopWidth

EndFunc   ;==>_SearchX

Func _Exit()
    Exit
EndFunc   ;==>_Exit

 

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

3 hours ago, JohnOne said:

If you have scite in full screen, and run this code from it, it should find the scite icon.

if there were 20 scite icons it would find them all.

You can figure out how to adapt it to your needs, and if you cannot, you are not ready to even try to write the code you want to.

I took replaced some magic numbers from original linked code.

Opt("PixelCoordMode", 1)
HotKeySet("{Esc}", "_Exit")

;Sleep(3000)
; Here you define the screen position of a known image
;  The image can be 1x1 pixels if you like
$__x = 10
$__y = 10
$__width = 10
$__height = 10
Sleep(3000)

; This part of code is getting the top left pixel color
;  and the checksum of the above defined area
$col = PixelGetColor($__x, $__y) ;Get top left color of checksum area
$sum = PixelChecksum($__x, $__y, $__x + $__width, $__y + $__height) ; Get checksum of area

; Here is the simple example
$timer = TimerInit()
_PictureSearch($col, $sum)
$time = TimerDiff($timer)
ConsoleWrite($time & @LF)



Func _PictureSearch($Color, $Checksum)
    $iX = @DesktopWidth
    $iY = @DesktopHeight
    $myY = 0
    Do
        $aPos = PixelSearch(0, $myY, $iX, $iY, $Color)
        If IsArray($aPos) Then
            If PixelChecksum($aPos[0], $aPos[1], $aPos[0] + $__width, $aPos[1] + $__height) = $Checksum Then
                MouseMove($aPos[0], $aPos[1], 0)
                Sleep(1000) ; Just to show it working
            EndIf
            _SearchX($aPos[0], $aPos[1])
            $myY = $aPos[1] + 1
        Else
            $myY = @DesktopHeight
        EndIf
    Until $myY >= @DesktopHeight
EndFunc   ;==>_PictureSearch

Func _SearchX($X, $Y)
    Local $a
    Do
        $a = PixelSearch($X + 1, $Y, @DesktopWidth, $Y, $col)
        If IsArray($a) Then
            $X = $a[0]
            If PixelChecksum($a[0], $a[1], $a[0] + $__width, $a[1] + $__height) = $sum Then
                MouseMove($a[0], $a[1], 0)
            EndIf
        Else
            $X = @DesktopWidth
        EndIf
    Until $X >= @DesktopWidth

EndFunc   ;==>_SearchX

Func _Exit()
    Exit
EndFunc   ;==>_Exit

 

Thanks I looked at the example, I opened a Pain and created a lot of pixels at row (red, yellow, green), and multiplied them throughout the document. And in the macro indicated the coordinate of the first red pixel followed by the desired color and indicated a width of 3 pixels and a height of 1 pixel. For a long time but he found them all. now I can't figure out how to putt him what he needs to look for being put into this checksum has these colors in this sequence xy(0.1)Red xy(0.2)Yellow xy(0.3)Green

Link to comment
Share on other sites

  • Moderators

Masheen,

When you reply, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - we know what we wrote and it just pads the thread unnecessarily. Thanks in advance for your cooperation.

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

Thanks I looked at the example, I opened a Pain and created a lot of pixels at row (red, yellow, green), and multiplied them throughout the document. And in the macro indicated the coordinate of the first red pixel followed by the desired color and indicated a width of 3 pixels and a height of 1 pixel. For a long time but he found them all. now I can't figure out how to putt him what he needs to look for being put into this checksum has these colors in this sequence xy(0.1)Red xy(0.2)Yellow xy(0.3)Green

Link to comment
Share on other sites

   Maybe like that. Plz amend and correct me

 

$aPosRed= PixelSearch(0, 0, @DesktopWidth,@DesktopHeight, 0xRed)
   if IsArray($aPosRed) Then
      $aPosYellow=PixelSearch($aPosRed[0]+1,$aPosRed[1],$aPosRed[0]+1,$aPosRed[1, 0xYellow)
      If IsArray($aPosYellow) Then
         $aPosGreen=PixelSearch($aPosYellow[0]+1,$aPosYellow[1],$aPosYellow[0]+1,$aPosYellow[1, 0xGreen)
         If IsArray($aPosYellow) Then
            MsgBox(0,"","GOOD")
         EndIf
      EndIf
   EndIf
   
      

Link to comment
Share on other sites

ok thx all. its work. I create in paint RedYellowGreen pixel row and do it code its find/ Thx all for help. By the way how i can edit my posts?

$myX=0
$myY=0
Do
   $aPosRed = PixelSearch(0, 260, @DesktopWidth,260, 0xED1C24)
   if IsArray($aPosRed) Then
      $aPosYellow = PixelSearch($aPosRed[0]+1,$aPosRed[1],$aPosRed[0]+1,$aPosRed[1], 0xFFF200)
      If IsArray($aPosYellow) Then
         $aPosGreen = PixelSearch($aPosYellow[0]+1,$aPosYellow[1],$aPosYellow[0]+1,$aPosYellow[1], 0x22B14C)
         If IsArray($aPosGreen) Then
            MsgBox(0,"","GOOD")
         EndIf
      EndIf
   EndIf
$myX=$myX+1
$myY=$myY+1
Until $myX=@DesktopWidth

 

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...