pixartist Posted February 4, 2006 Posted February 4, 2006 $dimension = _ImageGetSize ($szPicFile) Dim $imgPix[$dimension[0]][$dimension[1]] ;.... ;.... For $y = 0 To $dimension[1] - 1 For $x = 0 To $dimension[0] - 1 $ret = DllCall("gdi32.dll", "int", "GetPixel", "int", $hMemDC, "int", $x, "int", $y) $ret = Hex($ret[0], 6) $ret = StringRight($ret, 2) & StringMid($ret, 3, 2) & StringLeft($ret, 2) $imgPix[$y][$x] = $ret; Next Next return $imgPix C:\Dokumente und Einstellungen\FFS\Desktop\AU3scripts\loadImg.au3 (33) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $imgPix[$y][$x] = $ret; ^ ERROR help!
Developers Jos Posted February 4, 2006 Developers Posted February 4, 2006 shouldn't $imgPix[$y][$x] = $ret be $imgPix[$x][$y] = $ret ? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
pixartist Posted February 4, 2006 Author Posted February 4, 2006 not enough info _ImageGetSize ??? 8)#region - LazyCat;SEE THE FUNCTIONS WRITTEN BY LazyCat ;http://www.autoitscript.com/forum/index.php?s=&showtopic=4159&view=findpost&p=27240 Func _ImageGetSize ($sFile) Local $sHeader = _FileReadAtOffsetHEX ($sFile, 1, 24); Get header bytes Local $asIdent = StringSplit("FFD8 424D 89504E470D0A1A 4749463839 4749463837 4949 4D4D", " ") Local $anSize = "" If $asIdent[0] >= 2 And StringInStr($sHeader, $asIdent[2]) = 1 Then Return _ImageGetSizeSimple ($sHeader, 19, 23, 0) EndIf EndFunc
pixartist Posted February 4, 2006 Author Posted February 4, 2006 shouldn't $imgPix[$y][$x] = $ret be $imgPix[$x][$y] = $ret ?yep thx...
pixartist Posted February 4, 2006 Author Posted February 4, 2006 ARGHHH #include <loadImg.au3> $szPicFile = ".\test.bmp" $img = loadImg($szPicFile) $iy = 0 $ix = 0 $sx = 0 $sy = 0 while $ix*$iy < 1280*960 $val = PixelSearch ( $sx, $sy, $iy, $ix, $img[0][0] ) For $y = $val[1] To 19 For $x = $val[0] To 19 if $img[$y][$x] <> PixelGetColor ( $ix+$x, $iy+$y) then $sx = $ix+1 $sy = $iy ElseIf $x = 19 AND $y = 19 AND $img[$y][$x] == PixelGetColor ( $ix+$x, $iy+$y) Then MouseMove($ix+$x, $iy+$y) EndIf Next Next WEnd C:\Dokumente und Einstellungen\FFS\Desktop\AU3scripts\d2bot.au3 (11) : ==> Subscript used with non-Array variable.: For $y = $val[1]To 19 For $y = $val^ ERROR argh? why`???
greenmachine Posted February 4, 2006 Posted February 4, 2006 (edited) Did you check if @error was 1 after the pixelsearch call? I think you switched your x and y values again.... $val = PixelSearch ( $sx, $sy, $iy, $ix, $img[0][0] ) Don't you want it to be like this? $val = PixelSearch ( $sx, $sy, $ix, $iy, $img[0][0] ) Anothing thing: how big is the area of color that you're looking for (5 pixels by 5 pixels, or like.. 100x100)? It would go MUCH faster if you added a step into your pixelsearch. Edited February 4, 2006 by greenmachine
pixartist Posted February 4, 2006 Author Posted February 4, 2006 (edited) what im trying to do is: im loading a 20x20 pixel image ... then i wanna check if the 20x20 area is present on the screen... you got an idea how to do that? so far this seems to freeze: #include <loadImg.au3> $szPicFile = ".\test.bmp" $img = loadImg($szPicFile) $iy = 0 $ix = 0 $sx = 0 $sy = 0 while $ix*$iy < 1280*960 $val = PixelSearch ( $sx, $sy, $ix, $iy, $img[0][0] ) if NOT @error then For $y = $val[1] To 19 For $x = $val[0] To 19 if $img[$y][$x] <> PixelGetColor ( $ix+$x, $iy+$y) then $sx = $ix+1 $sy = $iy ElseIf $x = 19 AND $y = 19 AND $img[$y][$x] == PixelGetColor ( $ix+$x, $iy+$y) Then MouseMove($ix+$x, $iy+$y) EndIf Next Next if $ix < 1280 Then $ix = $ix +1 Else $ix = 0 $iy = $iy+1 EndIf EndIf WEnd Edited February 4, 2006 by pixartist
Valuater Posted February 4, 2006 Posted February 4, 2006 maybe $destination = @Systemdir & "\oobe\images\mslogo.jpg" SplashImageOn("Splash Screen", $destination,250,50) Sleep(5000) If WinExists("Splash Screen") Then MsgBox(64,"image test", "the image is on screen ") SplashOff() just an idea 8)
pixartist Posted February 4, 2006 Author Posted February 4, 2006 maybe $destination = @Systemdir & "\oobe\images\mslogo.jpg" SplashImageOn("Splash Screen", $destination,250,50) Sleep(5000) If WinExists("Splash Screen") Then MsgBox(64,"image test", "the image is on screen ") SplashOff() just an idea 8)lol of course i don't wanna check if an image is on the screen that i painted my own... #include <loadImg.au3> $szPicFile = ".\test.bmp" $img = loadImg($szPicFile) $iy = 0 $ix = 0 $sx = 0 $sy = 0 while $ix*$iy < 1280*960 $val = PixelSearch ( $sx, $sy, $ix, $iy, "0x" & $img[0][0] ) if NOT @error then For $y = $val[1] To 19 For $x = $val[0] To 19 if $img[$y][$x] <> PixelGetColor ( $ix+$x, $iy+$y) then $sx = $ix+1 $sy = $iy ElseIf $x = 19 AND $y = 19 AND $img[$y][$x] == PixelGetColor ( $ix+$x, $iy+$y) Then MouseMove($ix+$x, $iy+$y) EndIf Next Next if $ix < 1280 Then $ix = $ix +1 Else $ix = 0 $iy = $iy+1 EndIf EndIf WEnd it seems that $val = PixelSearch ( $sx, $sy, $ix, $iy, "0x" & $img[0][0] ) always returns error, even though $img[0][0] is a correct value..."0x" & $img[0][0] should be a hex value...
greenmachine Posted February 4, 2006 Posted February 4, 2006 Do this: MsgBox (0, "img[0][0] = ", $img[0][0]) right after the line $img = loadImg($szPicFile) and tell me what you get.
pixartist Posted February 4, 2006 Author Posted February 4, 2006 Do this: MsgBox (0, "img[0][0] = ", $img[0][0]) right after the line $img = loadImg($szPicFile) and tell me what you get.D4D08
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