nyxx24 Posted November 27, 2009 Share Posted November 27, 2009 Greetings, I would like to know if something is possible, if so how, and how difficult will it be. I have a script with an array with 17 sets of 4 coordinates. A left click selection followed by a right click selection. Each time my script runs it uses the first line in the array Then the next time the script loops the second line in the array is used and so on. Once all 17 lines have been used it starts over at the first line. What I want to know is if I add a pixel search to the loop.. Then for example when running the 5th line in the array and the pixel search is positive can it remove disable or disqualify, that 5th set of coordinates from the array so on the next complete loop it would only run the 16 remaining cooridinates and so on until none or only one of the coordinates remains? Let me know if further information is needed.. Thank you Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 27, 2009 Moderators Share Posted November 27, 2009 nyxx24, Add a 5th element to the array - then check if it is set before running that line - use the PixelSearch to set the element if required. Visual Example of intial array: x-coord 1 - y-coord 1 - x-coord 2 - y-coord 2 - flag 12 34 56 78 0 23 45 67 89 0 You put something like in your loop: If $aArray[$line][4] = 0 Then ; Run your code EndIf Then when Pixelsearch is positive for a particular line, you set the flag: $aArray[$line][4] = 1 So the array becomes, for example: x-coord 1 - y-coord 1 - x-coord 2 - y-coord 2 - flag 12 34 56 78 0 23 45 67 89 1 The next loop through, that line is ignored. I hope that helps. 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...
nyxx24 Posted November 27, 2009 Author Share Posted November 27, 2009 (edited) Thanks! I will try that and get back to you sometime this weekend Edited November 28, 2009 by nyxx24 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 27, 2009 Moderators Share Posted November 27, 2009 nyxx24,When you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read. and get back to you sometime this weekendDo you think I could go and play a round of golf or would you prefer I stayed in front of my machine the whole time? 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...
nyxx24 Posted November 28, 2009 Author Share Posted November 28, 2009 Ok.. sorry Link to comment Share on other sites More sharing options...
nyxx24 Posted November 28, 2009 Author Share Posted November 28, 2009 Dim $X = 0, $MouseClick[17][4]=[ _ [1111, 245, 1143, 254)], [1111, 264, 1143, 273)], _ [1111, 283, 1143, 293)], [1111, 302, 1143, 313)], _ [1111, 321, 1143, 333)], [1111, 340, 1143, 353)], _ [1111, 359, 1143, 373)], [1111, 376, 1143, 385)], _ [1111, 395, 1143, 405)], [1111, 414, 1143, 425)], _ [1111, 433, 1143, 445)], [1111, 452, 1143, 465)], _ [1111, 471, 1143, 485)], [1111, 490, 1143, 502)], _ [1111, 509, 1143, 522)], [1111, 528, 1143, 542)], _ [1111, 547, 1143, 558)]] While 1 If $X = 17 Then $X = 0 (more code) MouseClick("right", $MouseClick[$X][0], $MouseClick[$X][1]) Sleep(1000) MouseClick("left", $MouseClick[$X][2], $MouseClick[$X][3]) (more code) $X += 1 Wend Ok, Well I am not going to pretend I understand arrays.. it took time to even understand the one I have now.. I am not sure how to apply what you have suggested to what I have.. Link to comment Share on other sites More sharing options...
Authenticity Posted November 28, 2009 Share Posted November 28, 2009 (edited) #include <Array.au3> Dim $X = 0, $MouseClick[17][4]=[ _ [1111, 245, 1143, 254], [1111, 264, 1143, 273], _ [1111, 283, 1143, 293], [1111, 302, 1143, 313], _ [1111, 321, 1143, 333], [1111, 340, 1143, 353], _ [1111, 359, 1143, 373], [1111, 376, 1143, 385], _ [1111, 395, 1143, 405], [1111, 414, 1143, 425], _ [1111, 433, 1143, 445], [1111, 452, 1143, 465], _ [1111, 471, 1143, 485], [1111, 490, 1143, 502], _ [1111, 509, 1143, 522], [1111, 528, 1143, 542], _ [1111, 547, 1143, 558]] While 1 For $X = UBound($MouseClick)-1 To 0 Step -1 (more code) ; If pixel found MouseClick("right", $MouseClick[$X][0], $MouseClick[$X][1]) Sleep(1000) MouseClick("left", $MouseClick[$X][2], $MouseClick[$X][3]) ; ..and delete the entry _ArrayDelete($MouseClick, $X) (more code) Next If Not IsArray($MouseClick) Then ExitLoop Wend Edited November 28, 2009 by Authenticity Link to comment Share on other sites More sharing options...
JohnOne Posted November 28, 2009 Share Posted November 28, 2009 (edited) Ok, Well I am not going to pretend I understand arrays.. it took time to even understand the one I have now.. I am not sure how to apply what you have suggested to what I have.. You must understand enough to have written your code But I dont think you understood Melba23 very thourough explaination You need to add another dimension to your array, and give it a value, True or false I think may be appropriate. Your code should check that element dimention to decide whether to use the rest of them as its coords [1111,2222,3333,4444,True] it should use this [5555,6666,7777,8888,False] it should not use this I'm not certain Authenticiys code will work, as the help file says _ArrayDelete() only supports 2D arrays Edited November 28, 2009 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 More sharing options...
nyxx24 Posted November 28, 2009 Author Share Posted November 28, 2009 (edited) Thank you for the replies. If I failed to be clear I did not write the array. I will take in what has been provided and see what I can accomplish. Edited November 28, 2009 by nyxx24 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 28, 2009 Moderators Share Posted November 28, 2009 nyxx24, This is what I suggested earlier applied to your posted code: expandcollapse popup; Increase the array dimension by 1 and set the additional elements to 0 Global $MouseClick[17][5]=[ _ [1111, 245, 1143, 254, 0], [1111, 264, 1143, 273, 0], _ [1111, 283, 1143, 293, 0], [1111, 302, 1143, 313, 0], _ [1111, 321, 1143, 333, 0], [1111, 340, 1143, 353, 0], _ [1111, 359, 1143, 373, 0], [1111, 376, 1143, 385, 0], _ [1111, 395, 1143, 405, 0], [1111, 414, 1143, 425, 0], _ [1111, 433, 1143, 445, 0], [1111, 452, 1143, 465, 0], _ [1111, 471, 1143, 485, 0], [1111, 490, 1143, 502, 0], _ [1111, 509, 1143, 522, 0], [1111, 528, 1143, 542, 0], _ [1111, 547, 1143, 558, 0]] ; Start an infinite loop While 1 ; Zero a counter which we will use to break out of the infinite loop when all flags are set $iCount = 0 ; Run through the array - using For...Next saves having to set your own $X counter For $i = 0 To 16 ; Check if flag is set If $MouseClick[$i][4] = 0 Then ; It is not set so run the code (more code) MouseClick("right", $MouseClick[$X][0], $MouseClick[$X][1]) Sleep(1000) MouseClick("left", $MouseClick[$X][2], $MouseClick[$X][3]) (more code) ; Run your Pixelsearch PixelSearch(.....) ; If PixelSearch is successful, then set the flag for this array entry If Not @error Then $MouseClick[$i][4] = 1 EndIf ; Now count how many of the flags are set by adding them as we run through the 17 rows $iCount += $MouseClick[$i][4] ; If all 17 are set then exit both the For...Next and While...WEnd loops If $iCount = 17 Then ExitLoop 2 Next Wend Ask if anything is still unclear. 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...
nyxx24 Posted November 28, 2009 Author Share Posted November 28, 2009 Hello Again, So I tried various approaches lastnight before reading Melba's most recent post. I assumed $X needed to be changed to $i since $X was never declared in Melba's edited version of what I provided. So below is the test code which I tried to implement those suggestins in and I receive an error. Also note I reduced the array to 4 sets vs 17 to shorten the testing period. Here is the error: ============ Line 29 ..(the location of my script on the pc) If $MouseClick[$i][4] =0 Then If ^ Error Error: Array variable has an incorrect number of sunscriots or subscriot dimesion range exceeded. ============ expandcollapse popup#include <Array.au3> #include <Misc.au3> ;Insures only one instance of the script is running _Singleton("Test A", 0) ;Function keys to pause or terminate the script Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{END}", "Terminate") ;List of destinations and travel commands array Global $MouseClick[4][5] = [ _ [Random(1111, 1113), Random(245, 247), Random(1143, 1145), Random(252, 254), 0], _ [Random(1111, 1113), Random(264, 266), Random(1143, 1145), Random(271, 273), 0], _ [Random(1111, 1113), Random(283, 285), Random(1143, 1145), Random(291, 293), 0], _ [Random(1111, 1113), Random(302, 304), Random(1143, 1145), Random(311, 313), 0]] ;Start an infinite loop While 1 ;Zero a counter which we will use to break out of the infinite loop when all flags are set $iCount = 0 ;Run through the array - using For...Next saves having to set your own $X counter For $i = 0 To 4 ;Check if flag is set If $MouseClick[$i][4] = 0 Then ;It is not set so run the code MouseClick("right", $MouseClick[$i][0], $MouseClick[$i][1]) Sleep(1000) MouseClick("left", $MouseClick[$i][2], $MouseClick[$i][3]) ;Wait, set short for testing purposes Sleep(1000) ; Run your Pixelsearch PixelSearch(1431, 204, 1432, 205, 0XC1C1C1, 155) ; If PixelSearch is successful, then set the flag for this array entry and skip the remainder of the code If Not @error Then $MouseClick[$i][4] = 1 Else ; Here would be the remainder of my code. Which would only run on this loop if the pixel search fails EndIf ; Now count how many of the flags are set by adding them as we run through the 17 rows $iCount += $MouseClick[$i][4] ; If all 4 are set then exit both the For...Next and While...WEnd loops If $iCount = 4 Then ExitLoop 2 Next WEnd Func TogglePause() $Paused = Not $Paused While $Paused Sleep(100) ToolTip('Script is "Paused"', (1), (8), (1), (8)) WEnd ToolTip("") EndFunc ;==>TogglePause Func Terminate() Exit 0 EndFunc ;==>Terminate Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 28, 2009 Moderators Share Posted November 28, 2009 nyxx24, Remember that arrays begin at 0, so when you declare your array: Global $MouseClick[4][5] the first dimension has values 0, 1, 2, 3. When you try and run the loop: For $i = 0 To 4 you try and access 0, 1, 2, 3, 4. See where the problem lies? 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...
nyxx24 Posted November 28, 2009 Author Share Posted November 28, 2009 Yes I see my error. Excellent, in testing it appears to be working. Time for trial practical application. Thank you very much M23. In addition thank you Authenticity and JohnOne. 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