Jump to content

Declare?


Recommended Posts

  • Moderators

langthang084,

Please try and make the topic tiles a little more descriptive next time. :P

This should do what you want: :x

; Check for pixel
$p1 = PixelSearch(.....)
; If pixel is found
If Not @error Then
    ; Wait until it is no longer found
    Do
        Sleep(100)
        ; PixelSearch line MUST go just before the check for @error
        $p1 = PixelSearch(.....)
    Until @error
EndIf
; And we get here when the pixel is not found

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

My code like this:

$p1 = PixelSearch(.....)
$p2 = PixelSearch(.....)
$p3 = PixelSearch(.....)
$p4 = PixelSearch(.....)
.............
$p20 = PixelSearch(.....)


$p1 = PixelSearch(.....)
If Not @error Then
   Do
       Sleep(100)
       $p1 = PixelSearch(.....)
   Until @error
EndIf


$p2 = PixelSearch(.....)
If Not @error Then
   Do
       Sleep(100)
       $p2 = PixelSearch(.....)
   Until @error
EndIf
................

$p20 = PixelSearch(.....)
If Not @error Then
   Do
       Sleep(100)
       $p20 = PixelSearch(.....)
   Until @error
EndIf

Because the pixel coordinate maybe change so i want to declare it in 1 area (easy for rewrite this code). And the below will not be changed

Link to comment
Share on other sites

  • Moderators

langthang084,

Use an array to hold the area coordinates and then loop through them: :x

$aPixels[20][4] = [[10, 10, 20, 20], [20, 20, 40, 40], ....]]

; Look in each area
For $i = 0 To 19
    ; Check for pixel in this set of coordinates
    $iResult = PixelSearch($aPixels[$i][0], $aPixels[$i][1], $aPixels[$i][2], $aPixels[$i][3], $iColour)
    ; If pixel is found
    If Not @error Then
        ; Wait until it is no longer found
        Do
            Sleep(100)
            ; PixelSearch line MUST go just before the check for @error
            $iResult = PixelSearch($aPixels[$i][0], $aPixels[$i][1], $aPixels[$i][2], $aPixels[$i][3], $iColour)
        Until @error
    EndIf
Next
; And we get here when no pixels are found in any of the areas

If you want a different colour in each area, then just add a fith column to the array to hold it. :P

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 M23! It works!

But is there another way to declare like this:

$aPixels[20][4] = [[10, 10, 20, 20], 
                  [20, 20, 40, 40],
                       ....
                       ....
                  [...............]]

$aPixels[20][4] is written in 20 row (to easy to rewrite)

Link to comment
Share on other sites

  • Moderators

langthang084,

From the Help file:

Language Reference - Comments

Although only one statement per line is allowed, a long statement can span multiple lines if an underscore " _" preceded by a blank is placed at the end of a "broken" line.

So you can use: :x

$aPixels[20][4] = [[10, 10, 20, 20], _
                   [20, 20, 40, 40], _
                       ....
                       ....
                   [..............]]

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

  • Recently Browsing   0 members

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