Supericy Posted July 9, 2010 Share Posted July 9, 2010 (edited) expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** HotKeySet("{ESC}", "Terminate") Func Terminate() Exit 0 EndFunc #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> #include <Color.au3> #include <WinAPI.au3> #Include <GDIPlus.au3> _GDIPlus_Startup () Global $var, $timer = 0, $thres = 130, $width, $height, $x, $y, $drawX, $drawY, $draw = 0, $i, $progress, $msgbox = 0 $openx = FileOpen("draw.txt", 2) $hImage = FileOpenDialog ("Open image", @WorkingDir, "Images (*.jpg;*.jpeg;*.gif;*.png;*.bmp)", 1) If (@error) Then Exit $show = $hImage $hImage = _GDIPlus_ImageLoadFromFile($hImage) $height = _GDIPlus_ImageGetHeight($hImage) $width = _GDIPlus_ImageGetWidth($hImage) _GDIPlus_ImageDispose ($hImage) global $splitx[$width*$height] if($width>@desktopwidth) Then msgbox(0,"-ERROR","[IMAGE TOO WIDE]") Exit ElseIf($height>@DesktopHeight) Then msgbox(0,"-ERROR","[IMAGE TOO TALL]") Exit EndIf $GUI = GUICreate("DO NOT MOVE!",$width,$height+14,-4,-20,-1, $WS_EX_WINDOWEDGE & $WS_EX_TOPMOST) $imageBox = GUICtrlCreatePic($show,-1,-1, $width, $height) $progress = GUICtrlCreateProgress(0,$height,$width, 17, $PBS_SMOOTH) GUISetState () Opt("MouseClickDelay", 0) Opt("MouseClickDownDelay", 0) FindColours() Func FindColours() For $drawY = 0 to $height For $drawX = 0 to $width $colour = PixelGetColor($drawX, $drawY) $r = _ColorGetRed($colour) $g = _ColorGetGreen($colour) $b = _ColorGetBlue($colour) $shade = ($r + $g + $b)/3 If($shade<$thres) Then FileWrite($openx, "1") else FileWrite($openx, "0") EndIf $timer += 1 $i = ($timer/($width*$height))*100 GUICtrlSetData ($progress, $i) Next Next $GUI = GUIDelete() TrayTip("Scanning Done!", "Press F10 To Start! Make sure paint is open! ESC to Terminate!", 0) HotKeySet("{F10}", "Draw") while $Draw = 0 sleep(5000) wend EndFunc Func Draw() $drawX = 0 $Draw = 1 $timer = 0 FileClose($openx) $tempx = fileopen("draw.txt", 0) $sizeX = filegetsize("draw.txt") $openx = FileRead($tempx) $split = StringSplit($openx, "") $i = 1 For $drawY = 0 to $height For $drawX = 0 to $width mousemove($drawX+150, $drawY+150,0) if $split[$i] = 1 then mousemove($drawX+150, $drawY+150,0) mousedown("left") if isint($i/5) then sleep(1) endif while ($split[$i] = 1) and ($drawx < $width) mousemove($drawX+150, $drawY+150,0) $drawx += 1 $i += 1 wend mouseup("left") endif $i += 1 Next Next EndFunc So basically, this code will crudely scan an image and if the color of the pixel averages out above 130 it will write "1" to a file, otherwise it will write "0". So it works fine for some images, but for the majority of images it will give me this error: ImageCopierTXTv0.3test.au3 (105) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: I don't understand why it is giving me this error. Can anyone help me out? Edited July 9, 2010 by Supericy Link to comment Share on other sites More sharing options...
JohnOne Posted July 9, 2010 Share Posted July 9, 2010 I think its because in your draw func, you are incrementing $i twice in the same loop. 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...
Supericy Posted July 9, 2010 Author Share Posted July 9, 2010 (edited) I think its because in your draw func, you are incrementing $i twice in the same loop.I don't see how that would be the problem, and if it was the problem i don't think it would be giving me this error, as it doesn't make sense.Note: i tryed removing the 2nd $i increment(even tho this would break the draw) it still gave me the same error. Edited July 9, 2010 by Supericy Link to comment Share on other sites More sharing options...
JohnOne Posted July 9, 2010 Share Posted July 9, 2010 There is only one array in there as far as I can see, and that is at fault what line is line 105? 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...
Supericy Posted July 9, 2010 Author Share Posted July 9, 2010 (edited) There is only one array in there as far as I can see, and that is at fault what line is line 105? in the draw function, near the end: if $split[$i] = 1 then ^ Edited July 9, 2010 by Supericy Link to comment Share on other sites More sharing options...
Supericy Posted July 10, 2010 Author Share Posted July 10, 2010 Sorry for double post, can't edit my other post. The weirdest thing about this is that it works with only a single image. http://img576.imageshack.us/img576/9120/funnypicturesinterestin.jpg 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