Belfigor Posted August 3, 2008 Share Posted August 3, 2008 Hellow, i whant to ask help with that code: Func Test() $x=701 $y=439 $pc=0 $i=0 Do $var = PixelGetColor($x,$y) If $var = 0x000000 Then $i = $i+1 EndIf $pc=$pc+1 $y=$y+1 Until $pc = 19 MsgBox(0,"Black Pix: ", $i) EndFunc Test() Exit It will check an area 1x19 pixels for black color. After it script will show me how much black pixels was it that area. And how i can make script to show me coords of all black pixels in the area? [size="1"]My bear is so cute asleep in the closet, not even drinking vodka. My nuclear bomb name is Natasha.[/size] Link to comment Share on other sites More sharing options...
mafioso Posted August 3, 2008 Share Posted August 3, 2008 On each pixel-found, just do debug...something like ConsoleWrite($x & "," & $y & @CRLF). It will show all the found black pixels in AutoIt output (F8 in Scite if it's not there). Link to comment Share on other sites More sharing options...
Belfigor Posted August 3, 2008 Author Share Posted August 3, 2008 On each pixel-found, just do debug...something like ConsoleWrite($x & "," & $y & @CRLF). It will show all the found black pixels in AutoIt output (F8 in Scite if it's not there).And how can i use this coords in another part of script?I whant check the line, after checking script will return for me some coords. For example i will check a line where must be 3 black pixels, on coords: 701, 443; 701, 446; 701, 449. If true script will go to another step. If not true script will print a message. How i can make it? I tryed to search how to work with arrey, but nothing found I whant to make a script that will read words on a screen. [size="1"]My bear is so cute asleep in the closet, not even drinking vodka. My nuclear bomb name is Natasha.[/size] Link to comment Share on other sites More sharing options...
rambo3889 Posted August 3, 2008 Share Posted August 3, 2008 make an two dimensional array like : be aware this isn't tested dim $array[1][2] Func Test() $x=701 $y=439 $pc=0 $i=0 Do $var = PixelGetColor($x,$y) If $var = 0x000000 Then $i = $i+1 redim $array[$i][2] $array[$i-1][0]=$x $array[$i-1][1]=$y EndIf $pc=$pc+1 $y=$y+1 Until $pc = 19 for $1=0 to ubound($array)-1 consolewrite($array[$1][0]&@tab&$array[$1][1]) next MsgBox(0,"Black Pix: ", $i) EndFunc Test() Exit My Scripts:Radioblog Club Music DownloaderOther stuff:Fun movieIm serious read the help file it helps :PFight 'Till you drop. Never stop, You Cant give up. Til you reach the top Fight! youre the best in town Fight! Link to comment Share on other sites More sharing options...
Belfigor Posted August 3, 2008 Author Share Posted August 3, 2008 make an two dimensional array like : be aware this isn't tested dim $array[1][2] Func Test() $x=701 $y=439 $pc=0 $i=0 Do $var = PixelGetColor($x,$y) If $var = 0x000000 Then $i = $i+1 redim $array[$i][2] $array[$i-1][0]=$x $array[$i-1][1]=$y EndIf $pc=$pc+1 $y=$y+1 Until $pc = 19 for $1=0 to ubound($array)-1 consolewrite($array[$1][0]&@tab&$array[$1][1]) next MsgBox(0,"Black Pix: ", $i) EndFunc Test() ExitI cannot make it work. I dont know anything about arrays and how to use them, and dont know where to find a good manual . Looked in Help, but dont understand anything [size="1"]My bear is so cute asleep in the closet, not even drinking vodka. My nuclear bomb name is Natasha.[/size] Link to comment Share on other sites More sharing options...
D4rk^S0ul Posted August 3, 2008 Share Posted August 3, 2008 If you use a simple array it is just used like $Array[0] $Array[1] etc so if you add 5 things into a array it will be $Array[0-5] so if you need 2 arrays for x and y so add somethin like a counter starting 0 and going up by 1 each time you loop then have 2 arrays eg. $Array1 and $Array2 then use the counter to find out how many there are so it will be $Array1[0 - the current counter number], and $Array2 doing the same so MouseMove($Array1[0], $Array2[0]) MouseMove($Array1[1], $Array2[1]) and keep doing that untill you get to the final array and that will redo all the mouse movements you have in them arrays Link to comment Share on other sites More sharing options...
Belfigor Posted August 4, 2008 Author Share Posted August 4, 2008 (edited) Very big thanks for every one, espesialy for D4rk^S0ul!!! But i have one more question. Now i understand how to use an array, but how can i make an array? I tested this code: $x[0]=0 $y[0]=0 $x[1]=100 $y[1]=100 $x[2]=200 $y[2]=200 $x[3]=300 $y[3]=300 $x[4]=400 $y[4]=400 MsgBox(0,"Coords",$x[0]) What commands i miss in that script? Edited August 4, 2008 by Belfigor [size="1"]My bear is so cute asleep in the closet, not even drinking vodka. My nuclear bomb name is Natasha.[/size] Link to comment Share on other sites More sharing options...
Triblade Posted August 4, 2008 Share Posted August 4, 2008 (edited) Something like: ? Dim $i, $x, $y, $array[19][1] ; Two-dimensional array, [19] says 20 entries max, [1] says 2 entries max (0 is an entry as well) :) For $i = 0 To 19 ; Changed your loop to the: For..Next. If PixelGetColor($x, $y) = $COLOR Then $array[$i][0] = $x ;Add X coord to $array1 $array[$i][1] = $y ;Add Y coord to $array2 EndIf $y = $y+1 $i = $i+1 Next MsgBox(0, "Content $i = 0", "X-coordinate: $array[0][0] = " & $array[0][0] & @CRLF & "Y-coordinate: $array[0][1] = " & $array[0][1]) Edited August 4, 2008 by Triblade My active project(s): A-maze-ing generator (generates a maze) My archived project(s): Pong3 (Multi-pinger) Link to comment Share on other sites More sharing options...
Belfigor Posted August 4, 2008 Author Share Posted August 4, 2008 Something like: ? Dim $i, $x, $y, $array[19][1] ; Two-dimensional array, [19] says 20 entries max, [1] says 2 entries max (0 is an entry as well) :) For $i = 0 To 19 ; Changed your loop to the: For..Next. If PixelGetColor($x, $y) = $COLOR Then $array[$i][0] = $x ;Add X coord to $array1 $array[$i][1] = $y ;Add Y coord to $array2 EndIf $y = $y+1 $i = $i+1 Next MsgBox(0, "Content $i = 0", "X-coordinate: $array[0][0] = " & $array[0][0] & @CRLF & "Y-coordinate: $array[0][1] = " & $array[0][1])oÝ÷ Ûú®¢×©äʺǶ¬½ªâjبÊÊ«±Êâ¦Ö®¶sdFÒb33c¶Âb33c¶'&³Õ³Ò²GvòÖFÖVç6öæÂ'&³Ò62#VçG&W2Ö³Ò62"VçG&W2Ö2âVçG'2vVÆ¢b33c·Òs¢b33c·ÒC3¢b33c´4ôÄõ"Ò¤f÷"b33c¶ÒFò²6ævVB÷W"Æö÷FòFS¢f÷"âäæWBà¢bVÄvWD6öÆ÷"b33c·Âb33c·Òb33c´4ôÄõ"FVà¢b33c¶'&²b33c¶Õ³ÒÒb33c·´FB6ö÷&BFòb33c¶'&²b33c¶Õ³Ð¢b33c¶'&²b33c¶Õ³ÒÒb33c·´FB6ö÷&BFòb33c¶'&²b33c¶Õ³Ð¢VæD`¢b33c·Òb33c·³¢b33c¶Òb33c¶³¤æW@¤×6t&÷ÂgV÷C´6öçFVçBb33c¶ÒgV÷C²ÂgV÷CµÖ6ö÷&FæFS¢b33c¶'&³Õ³ÒÒgV÷C²fײb33c¶'&³Õ³Òfײ5$ÄbfײgV÷CµÖ6ö÷&FæFS¢b33c¶'&³Õ³ÒÒgV÷C²fײb33c¶'&³Õ³Ò I think it must work, but i cannot test it normaly, because it give back an error, telling thet there are an error in MsgBox, and i dont know how to use arrays in MsgBox error: [size="1"]My bear is so cute asleep in the closet, not even drinking vodka. My nuclear bomb name is Natasha.[/size] Link to comment Share on other sites More sharing options...
rambo3889 Posted August 4, 2008 Share Posted August 4, 2008 The error is at first line: Dim $i, $array[19][1]; Two-dimensional array, [19] says 20 entries max, [1] says 2 entries max (0 is an entry as well) This is infact wrong, your array can only hold 19 entries 0-18 and your for loop goes from 0 to 19 thats 20 entries instead of the 19 that you declared. [1] says max 2 entries is also wrong, even though arrays are indexed from 0 and up when they are declared you can't count the 0 in that. As an example see this: Dim $colors[2][3];This array will hold my favourite colors and the colors that i disguest the most:. [0][] will be the favs and [1][] will be the disgusting ones $colors[0][0]="Red" $colors[0][1]="Green" $colors[0][2]="Black" $colors[1][0]="White" $colors[1][1]="Blue" $colors[1][2]="Yellow" A quick fix to your problem would be: Dim $i, $array[20][2]; Two-dimensional array, [19] says 20 entries max, [1] says 2 entries max (0 is an entry as well) $x = 70 $y = 438 $COLOR = 0x000000 For $i = 0 To 19; Changed your loop to the: For..Next. If PixelGetColor($x, $y) = $COLOR Then $array[$i][0] = $x ;Add X coord to $array[$i][0] $array[$i][1] = $y ;Add Y coord to $array[$i][1] EndIf $y = $y+1 $i = $i+1 Next MsgBox(0, "Content $i = 0", "X-coordinate: $array[0][0] = " & $array[0][0] & @CRLF & "Y-coordinate: $array[0][1] = " & $array[0][1]) My Scripts:Radioblog Club Music DownloaderOther stuff:Fun movieIm serious read the help file it helps :PFight 'Till you drop. Never stop, You Cant give up. Til you reach the top Fight! youre the best in town Fight! Link to comment Share on other sites More sharing options...
Triblade Posted August 4, 2008 Share Posted August 4, 2008 (edited) The error is at first line: Dim $i, $array[19][1]; Two-dimensional array, [19] says 20 entries max, [1] says 2 entries max (0 is an entry as well) This is infact wrong, your array can only hold 19 entries 0-18 and your for loop goes from 0 to 19 thats 20 entries instead of the 19 that you declared.Darn it. I allways get that wrong Well, thanks for the fix rambo3889! Edited August 4, 2008 by Triblade My active project(s): A-maze-ing generator (generates a maze) My archived project(s): Pong3 (Multi-pinger) Link to comment Share on other sites More sharing options...
Belfigor Posted August 4, 2008 Author Share Posted August 4, 2008 Perfect! PERFECT!!! The last script can do everything i need! Thank you all! Thank you very much! Few more questions : 1) Dim $array[20][2]oÝ÷ ÙhØb²X§z,"W+y«^jºÚËm^ÚâzȧÖËi¢ÈÚÝÞÚâzȧÚwi¢ÈÒ¢,!j{m¡«$iº.¶Øb²X§y:æyªëk,"¶é¢ÈìwvÚ.±æ®¶sdFÒb33c¶'&´åÕ´åÕ´å For array with 4 positions [N][N][N][N] etc? - Is there a limit for number of positions ([20][2] - i just dont know how to name them correctly)? [size="1"]My bear is so cute asleep in the closet, not even drinking vodka. My nuclear bomb name is Natasha.[/size] Link to comment Share on other sites More sharing options...
rambo3889 Posted August 4, 2008 Share Posted August 4, 2008 1: No it wil create 20 entries which goes from 0 to 19 and has 2 sub items which goes from 0 to 1 .Arrays: A maximum of 64 dimensions and/or a total of 16 million elements from the FAQ note 15 about limits.I recommend that you read this page, it will give you a quite good knowlegde of arrays : http://www.autoitscript.com/wiki/Arrays My Scripts:Radioblog Club Music DownloaderOther stuff:Fun movieIm serious read the help file it helps :PFight 'Till you drop. Never stop, You Cant give up. Til you reach the top Fight! youre the best in town Fight! Link to comment Share on other sites More sharing options...
Belfigor Posted August 4, 2008 Author Share Posted August 4, 2008 Thank you every one who helped me with my script. I thnik it will be good information for every one who first time used arrays in his script. Tags: Arrays, $Arrays, Help with an arrays, Dim, Help with Dim, How to use Arrays. [size="1"]My bear is so cute asleep in the closet, not even drinking vodka. My nuclear bomb name is Natasha.[/size] Link to comment Share on other sites More sharing options...
Belfigor Posted August 5, 2008 Author Share Posted August 5, 2008 (edited) Once agein, it is me . Tell me please, why i cannot make that simple scripts to work? Dim $JXC[14] = [698, 699, 700, 701, 702, 702, 702, 702, 702, 702, 702, 702, 702] Dim $JYC[14] = [451, 452, 452, 452, 451, 450, 449, 448, 447, 446, 445, 444, 443] Test() Exit Func Test() MsgBox(0, "Coords", &$JXC[2]& @CRLF &$JYC[2]&) EndFuncoÝ÷ Ù«¢+Ù¥´ÀÌØí) lÄÑulÄÑtômlØäà°Øää°ÜÀÀ°ÜÀÄ°ÜÀÈ°ÜÀÈ°ÜÀÈ°ÜÀÈ°ÜÀÈ°ÜÀÈ°ÜÀÈ°ÜÀÈ°ÜÀÉt°lÐÔÄ°ÐÔÈ°ÐÔÈ°ÐÔÈ°ÐÔÄ°ÐÔÀ°ÐÐä°ÐÐà°ÐÐÜ°ÐÐØ°ÐÐÔ°ÐÐаÐÐÍut)QÍÐ ¤)á¥Ð()Õ¹QÍÐ ¤)5Í ½à À°ÅÕ½Ðí ½½ÉÌÅÕ½Ðì°ÀÌØí) lÉulÉt¤)¹Õ¹ Edited August 5, 2008 by Belfigor [size="1"]My bear is so cute asleep in the closet, not even drinking vodka. My nuclear bomb name is Natasha.[/size] Link to comment Share on other sites More sharing options...
Belfigor Posted August 5, 2008 Author Share Posted August 5, 2008 Up [size="1"]My bear is so cute asleep in the closet, not even drinking vodka. My nuclear bomb name is Natasha.[/size] Link to comment Share on other sites More sharing options...
herewasplato Posted August 5, 2008 Share Posted August 5, 2008 Your msgbox was not formatted correctlyDim $JXC[14] = [698, 699, 700, 701, 702, 702, 702, 702, 702, 702, 702, 702, 702] Dim $JYC[14] = [451, 452, 452, 452, 451, 450, 449, 448, 447, 446, 445, 444, 443] Test() Exit Func Test() MsgBox(0, "Coords", $JXC[2] & @CRLF & $JYC[2]) EndFunc ;==>TestoÝ÷ Ù.v趯y©ò½©nzƬ²('yÛhÛf®¶sdFÒb33c´¤5³EÕ³EÒÒµ³cÂcÂsÂsÂs"Âs"Âs"Âs"Âs"Âs"Âs"Âs"Âs%ÒųCSÂCS"ÂCS"ÂCS"ÂCSÂCSÂCCÂCCÂCCrÂCCbÂCCRÂCCBÂCC5ÕÐ¥FW7B¤W@ ¤gVæ2FW7B¢×6t&÷ÂgV÷C´6ö÷&G2gV÷C²Âb33c´¤5³Õ³%Ò¤VæDgVæ2³ÓÒfwCµFW7@ [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
herewasplato Posted August 5, 2008 Share Posted August 5, 2008 This line: Dim $JC[2][13] = [[698, 699, 700, 701, 702, 702, 702, 702, 702, 702, 702, 702, 702],[451, 452, 452, 452, 451, 450, 449, 448, 447, 446, 445, 444, 443]] Creates this: $JC[0][0] = 698 $JC[0][1] = 699 $JC[0][2] = 700 $JC[0][3] = 701 $JC[0][4] = 702 ....... $JC[0][13] = 702 $JC[1][0] = 451 $JC[1][1] = 452 $JC[1][2] = 452 $JC[1][3] = 452 $JC[1][4] = 451 ....... $JC[1][13] = 443 [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Belfigor Posted August 5, 2008 Author Share Posted August 5, 2008 This line: Dim $JC[2][13] = [[698, 699, 700, 701, 702, 702, 702, 702, 702, 702, 702, 702, 702],[451, 452, 452, 452, 451, 450, 449, 448, 447, 446, 445, 444, 443]] Creates this: $JC[0][0] = 698 $JC[0][1] = 699 $JC[0][2] = 700 $JC[0][3] = 701 $JC[0][4] = 702 ....... $JC[0][13] = 702 $JC[1][0] = 451 $JC[1][1] = 452 $JC[1][2] = 452 $JC[1][3] = 452 $JC[1][4] = 451 ....... $JC[1][13] = 443Then why i cannot use this vars as X,Y coords in my massage box? [size="1"]My bear is so cute asleep in the closet, not even drinking vodka. My nuclear bomb name is Natasha.[/size] Link to comment Share on other sites More sharing options...
herewasplato Posted August 5, 2008 Share Posted August 5, 2008 Then why i cannot use this vars as X,Y coords in my massage box?tryDim $JC[2][13] = [[698, 699, 700, 701, 702, 702, 702, 702, 702, 702, 702, 702, 702],[451, 452, 452, 452, 451, 450, 449, 448, 447, 446, 445, 444, 443]] Test() Exit Func Test() MsgBox(0, "Coords", $JC[0][2] & @CR & $JC[1][2]) EndFunc ;==>Test [size="1"][font="Arial"].[u].[/u][/font][/size] 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