langthang084 Posted January 5, 2011 Share Posted January 5, 2011 I want to declare like this: $p1=pixelsearch(........) If $p1 <>@error then do sleep(100) Until $p1=@error endif But it's not work. Could anyone help me Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 5, 2011 Moderators Share Posted January 5, 2011 langthang084, Please try and make the topic tiles a little more descriptive next time. This should do what you want: ; 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 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
langthang084 Posted January 6, 2011 Author Share Posted January 6, 2011 I want to check 20 pixel, so the code is long and complex. Is there anyway more simple? Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted January 6, 2011 Share Posted January 6, 2011 Your question is not very clear, do you want to create a function? See the page "Func...Return...EndFunc" in helpfile. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
langthang084 Posted January 6, 2011 Author Share Posted January 6, 2011 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 More sharing options...
Moderators Melba23 Posted January 6, 2011 Moderators Share Posted January 6, 2011 langthang084, Use an array to hold the area coordinates and then loop through them: $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. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
langthang084 Posted January 6, 2011 Author Share Posted January 6, 2011 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 More sharing options...
Moderators Melba23 Posted January 6, 2011 Moderators Share Posted January 6, 2011 langthang084,From the Help file:Language Reference - CommentsAlthough 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: $aPixels[20][4] = [[10, 10, 20, 20], _ [20, 20, 40, 40], _ .... .... [..............]]M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now