Skitty Posted July 25, 2011 Posted July 25, 2011 Ok, so I'll be honest, I was going to try to come up with some BS about how I need a drawing script for my grandma, but this isn't the case and its total bull just like those other posts that say they need to hide a certain process and disable taskmgr.exe and prevent UAC from working because they work in as a system admin at some non-existent school they just made up and need to keep the children from running an antivirus.My point is I'm looking for a script that will create an image in http://flockdraw.com/AutoIt using another image you supplied the script with, by what I know, this isn't against their usage terms etc.I'm interested in having a script that can magically draw into the white board and even select hues and change contrast using wizardry, the best I've came up with was a script that lays out black dots which is worthless and shallow.If I'm missing something here and this sort of automation falls under the same category as key-loggers and game bots, well, I'll just move along, if it doesn't, than great! I really wan't to be able to impress my friends with this voodoo stuff.Dumb jokes aside, if there's some kind of usage policy against this, I'll abide by it.
JohnOne Posted July 25, 2011 Posted July 25, 2011 Crikey! Settle down son, you just want to automate paint.exe? I've wondered this before, and the furthest I got was opening an image with paints commandline Run("mspaint.exe path\to\image.jpg") As for the rest of the black magic, I'd love to know too. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Skitty Posted July 25, 2011 Author Posted July 25, 2011 Crikey! Settle down son, you just want to automate paint.exe?I've wondered this before, and the furthest I got was opening an image with paints commandline Run("mspaint.exe path\to\image.jpg")As for the rest of the black magic, I'd love to know too.Yeah, I'd love to get a copy of somescript that could do this, although, I do recall seeing a video of somebody doing exactly what I said using autoit on youtube, and I'd have thought that person would have made a post somewhere around here but that doesn't seem to be the case...
JoHanatCent Posted July 25, 2011 Posted July 25, 2011 Yeah, I'd love to get a copy of somescript that could do this, although, I do recall seeing a video of somebody doing exactly what I said using autoit on youtube, and I'd have thought that person would have made a post somewhere around here but that doesn't seem to be the case...Try If you uncomment line 170 there will be no errors.
Skitty Posted July 25, 2011 Author Posted July 25, 2011 (edited) Try If you uncomment line 170 there will be no errors. Awesome, that's more or less what I was looking for, except I would have imagined someone making a script that would build a color profile on the image, sort of like the little dots on a newspaper, than have the script print it back out selecting colors from a pallet etc. I'll try to work on this script. Thanks. Edit: that post was an bad version of the same one out there.. expandcollapse popup#include <GUIConstants.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> #include <Color.au3> #include <WinAPI.au3> Global $threshold Global $image Global $width Global $height Global $pixels Global $pathString = "12345678" Global $scramble = False Global $rotate = 0 Global $speed ;; Check hotkeys ;; If (Not HotKeySet ("{F9}", "Nothing")) Then MsgBox (16, "Error", "Could not register the F9 hotkey.") Exit EndIf If (Not HotKeySet ("{F10}", "Nothing")) Then MsgBox (16, "Erro", "Could not register the F10 hotkey.") Exit EndIf ;; Image dialog ;; $imageFile = FileOpenDialog ("Open image", @WorkingDir, "Images (*.jpg;*.jpeg;*.gif;*.png;*.bmp)", 1) If (@error) Then Exit ;; Options dialog ;; $optGUI = GUICreate ("Settings", 160, 270, -1, -1, $WS_CAPTION, BitOr ($WS_EX_APPWINDOW, $WS_EX_TOOLWINDOW)) GUICtrlCreateGroup ("Image processing", 5, 5, 150, 85) GUICtrlCreateLabel ("Sensitivity (0~255):", 10, 28, 110, 15) $thresholdInput = GUICtrlCreateInput ("100", 125, 25, 25, 20, $ES_NUMBER) GUICtrlCreateLabel ("Width (px):", 10, 48, 110, 15) $widthInput = GUICtrlCreateInput ("100", 125, 45, 25, 20, $ES_NUMBER) GUICtrlCreateLabel ("Height (px):", 10, 68, 110, 15) $heightInput = GUICtrlCreateInput ("100", 125, 65, 25, 20, $ES_NUMBER) GUICtrlCreateGroup ("Drawing pattern", 5, 95, 150, 140) $horizontalRadio = GUICtrlCreateRadio ("Horizontal", 10, 115, 110, 15) $verticalRadio = GUICtrlCreateRadio ("Vertical", 10, 135, 110, 15) $diagonalRadio = GUICtrlCreateRadio ("Diagonal", 10, 155, 110, 15) $rotateRadio = GUICtrlCreateRadio ("Spiral", 10, 175, 110, 15) $scrambleRadio = GUICtrlCreateRadio ("Random", 10, 195, 110, 15) GUICtrlSetState ($diagonalRadio, $GUI_CHECKED) GUICtrlCreateLabel ("Mouse speed (0~100):", 10, 213, 110, 15) $speedInput = GUICtrlCreateInput ("0", 125, 210, 25, 20, $ES_NUMBER) $okBtn = GUICtrlCreateButton ("Ok", 30, 245, 40, 20) $cancelBtn = GUICtrlCreateButton ("Cancel", 80, 245, 50, 20) GUISetState () While 1 Switch (GUIGetMsg ()) Case $GUI_EVENT_CLOSE Exit Case $cancelBtn Exit Case $okBtn $threshold = GUICtrlRead ($thresholdInput) $width = GUICtrlRead ($widthInput) $height = GUICtrlRead ($heightInput) $speed = GUICtrlRead ($speedInput) If (GUICtrlRead ($horizontalRadio) == $GUI_CHECKED) Then $pathString = "45273618" ElseIf (GUICtrlRead ($verticalRadio) == $GUI_CHECKED) Then $pathString = "27453618" ElseIf (GUICtrlRead ($diagonalRadio) == $GUI_CHECKED) Then $pathString = "36184527" ElseIf (GUICtrlRead ($rotateRadio) == $GUI_CHECKED) Then $pathString = "14678532" $rotate = 1 ElseIf (GUICtrlRead ($scrambleRadio) == $GUI_CHECKED) Then $scramble = True EndIf GUIDelete ($optGUI) ExitLoop EndSwitch WEnd ;; Processing dialog ;; $GUI = GUICreate ("Processing image...", $width, $height + 20, -1, -1, $WS_CAPTION, BitOr ($WS_EX_APPWINDOW, $WS_EX_TOOLWINDOW)) GUISetBkColor (0xffffff) $imageBox = GUICtrlCreatePic ($imageFile, 0, 0, $width, $height) $progress = GUICtrlCreateProgress (0, $height, $width, 20) GUISetState () ;; Get image pixels ;; $dc = _WinAPI_GetDC ($GUI) $memDc = _WinAPI_CreateCompatibleDC ($dc) $bitmap = _WinAPI_CreateCompatibleBitmap ($dc, $width, $height) _WinAPI_SelectObject ($memDc, $bitmap) _WinAPI_BitBlt ($memDc, 0, 0, $width, $height, $dc, 0, 0, $SRCCOPY) $bits = DllStructCreate ("dword[" & ($width * $height) & "]") DllCall ("gdi32", "int", "GetBitmapBits", "ptr", $bitmap, "int", ($width * $height * 4), "ptr", DllStructGetPtr ($bits)) GUICtrlDelete ($imageBox) ;; Process the pixels ;; Dim $pixels[$width][$height] For $y = 0 To ($height - 1) For $x = 0 To ($width - 1) $index = ($y * $width) + $x $color = DllStructGetData ($bits, 1, $index) $red = _ColorGetBlue ($color) $green = _ColorGetGreen ($color) $blue = _ColorGetRed ($color) $shade = ($red + $green + $blue) / 3 If ($shade > $threshold) Then $color = 0xffffff $pixels[$x][$y] = 0 Else $color = 0 $pixels[$x][$y] = 1 EndIf DllStructSetData ($bits, 1, $color, $index) Next DllCall ("gdi32", "int", "SetBitmapBits", "ptr", $bitmap, "int", ($width * $height * 4), "ptr", DllStructGetPtr ($bits)) _WinAPI_BitBlt ($dc, 0, 0, $width, $height, $memDc, 0, 0, $SRCCOPY) GUICtrlSetData ($progress, ($y * 100) / $height) Next _WinAPI_ReleaseDC ($GUI, $dc) GUIRegisterMsg ($WM_PAINT, "OnPaint") ;; Ready to draw ;; TrayTip ("Pronto!", "Press F9 para draw. You can press F10 anytime to exit.", 10) HotKeySet ("{F9}", "Draw") HotKeySet ("{F10}", "Quit") While 1 Sleep (60000) WEnd Func OnPaint ($hwndGUI, $msgID, $wParam, $lParam) Local $paintStruct = DllStructCreate ("hwnd hdc;int fErase;dword rcPaint[4];int fRestore;int fIncUpdate;byte rgbReserved[32]") $dc = DllCall ("user32", "hwnd", "BeginPaint", "hwnd", $hwndGUI, "ptr", DllStructGetPtr ($paintStruct)) $dc = $dc[0] _WinAPI_BitBlt ($dc, 0, 0, $width, $height, $memDc, 0, 0, $SRCCOPY) DllCall ("user32", "hwnd", "EndPaint", "hwnd", $hwndGUI, "ptr", DllStructGetPtr ($paintStruct)) Return $GUI_RUNDEFMSG EndFunc Func Draw () $mouseCenter = MouseGetPos () $x0 = $mouseCenter[0] - ($width / 2) $y0 = $mouseCenter[1] - ($height / 2) ;; Move the mouse around the drawing perimeter ;; MouseMove ($x0, $y0) MouseMove ($x0 + $width, $y0) MouseMove ($x0 + $width, $y0 + $height) MouseMove ($x0, $y0 + $height) MouseMove ($x0, $y0) ;; Draw all the areas ;; $stack = CreateStack (1000) For $y = 0 To ($height - 1) For $x = 0 To ($width - 1) If ($pixels[$x][$y] == 1) Then MouseMove ($x + $x0, $y + $y0, $speed) MouseDown ("primary") DrawArea ($stack, $x, $y, $x0, $y0) MouseUp ("primary") Else EndIf Next Next ;; Reset the pixels statuses ;; For $y = 0 To ($height - 1) Step 1 For $x = 0 To ($width - 1) Step 1 If ($pixels[$x][$y] == 2) Then $pixels[$x][$y] = 1 EndIf Next Next EndFunc Func DrawArea (ByRef $stack, $x, $y, $x0, $y0) Local $path[8] Local $continue $path = MakePath ($pathString) While 1 MouseMove ($x + $x0, $y + $y0, $speed) $pixels[$x][$y] = 2 If ($scramble) Then ScramblePath ($path) If ($rotate > 0) Then RotatePath ($path, $rotate) ;;;;;;;;;;;;;;;;;;; ;; +---+---+---+ ;; ;; | 1 | 2 | 3 | ;; ;; +---+---+---+ ;; ;; | 4 | | 5 | ;; ;; +---+---+---+ ;; ;; | 6 | 7 | 8 | ;; ;; +---+---+---+ ;; ;;;;;;;;;;;;;;;;;;; $continue = False For $i = 0 To 7 Switch ($path[$i]) Case 1 If (($x > 0) And ($y > 0)) Then If ($pixels[$x - 1][$y - 1] == 1) Then Push ($stack, $x, $y) $x -= 1 $y -= 1 $continue = True ExitLoop EndIf EndIf Case 2 If ($y > 0) Then If ($pixels[$x][$y - 1] == 1) Then Push ($stack, $x, $y) $y -= 1 $continue = True ExitLoop EndIf EndIf Case 3 If (($x > 0) And ($y < 0)) Then If ($pixels[$x + 1][$y - 1] == 1) Then Push ($stack, $x, $y) $x += 1 $y -= 1 $continue = True ExitLoop EndIf EndIf Case 4 If ($x > 0) Then If ($pixels[$x - 1][$y] == 1) Then Push ($stack, $x, $y) $x -= 1 $continue = True ExitLoop EndIf EndIf Case 5 If ($x < ($width - 1)) Then If ($pixels[$x + 1][$y] == 1) Then Push ($stack, $x, $y) $x += 1 $continue = True ExitLoop EndIf EndIf Case 6 If (($x < 0) And ($y > 0)) Then If ($pixels[$x - 1][$y + 1] == 1) Then Push ($stack, $x, $y) $x -= 1 $y += 1 $continue = True ExitLoop EndIf EndIf Case 7 If ($y < ($height - 1)) Then If ($pixels[$x][$y + 1] == 1) Then Push ($stack, $x, $y) $y += 1 $continue = True ExitLoop EndIf EndIf Case 8 If (($x < ($width - 1)) And ($y < ($height - 1))) Then If ($pixels[$x + 1][$y + 1] == 1) Then Push ($stack, $x, $y) $x += 1 $y += 1 $continue = True ExitLoop EndIf EndIf EndSwitch Next If ($continue) Then ContinueLoop If (Not Pop ($stack, $x, $y)) Then ExitLoop WEnd EndFunc Func MakePath ($string) Return StringSplit ($string, "") EndFunc Func ScramblePath (ByRef $path) Local $table = "12345678" Local $newPath[8] For $i = 8 To 1 Step -1 $next = StringMid ($table, Random (1, $i, 1), 1) $newPath[$i - 1] = Number ($next) $table = StringReplace ($table, $next, "") Next $path = $newPath EndFunc Func RotatePath (Byref $path, $places) If ($places == 0) Then Return $path Else For $i = 1 To Abs ($places) $temp = $path[7] $path[7] = $path[6] $path[6] = $path[5] $path[5] = $path[4] $path[4] = $path[3] $path[3] = $path[2] $path[2] = $path[1] $path[1] = $path[0] $path[0] = $temp Next EndIf EndFunc Func CreateStack ($size) Dim $stack[$size + 1][2] $stack[0][0] = 0 $stack[0][1] = $size Return $stack EndFunc Func Push (ByRef $stack, $x, $y) $stack[0][0] += 1 If ($stack[0][0] > $stack[0][1]) Then $stack[0][1] += 1000 ReDim $stack[$stack[0][1] + 1][2] EndIf $stack[$stack[0][0]][0] = $x $stack[$stack[0][0]][1] = $y EndFunc Func Pop (ByRef $stack, ByRef $x, ByRef $y) If ($stack[0][0] < 1) Then Return False EndIf $x = $stack[$stack[0][0]][0] $y = $stack[$stack[0][0]][1] $stack[0][0] -= 1 Return True EndFunc Func Nothing () EndFunc Func Quit () MouseUp ("primary") Exit EndFunc Edit#2: Made my own little version, makes the drawing stoppable without exiting the script and having to reload an image. expandcollapse popup#include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <EditConstants.au3> #include <GUIConstants.au3> #include <WinAPI.au3> #include <Color.au3> #include <Misc.au3> If (Not HotKeySet("{F9}", "Nothing")) Then MsgBox(16, "Error", "Could not register the F9 hotkey.") Exit EndIf If (Not HotKeySet("{F10}", "Quit")) Then MsgBox(16, "Error", "Could not register the F10 hotkey.") Exit EndIf Global $iX1, $iY1, $iX2, $iY2, $aPos, $sMsg, $sBMP_Path Global $threshold, $memDc Global $image, $GUI, $drwstate = False Global $width Global $height Global $pixels Global $pathString = "12345678" Global $scramble = False Global $rotate = 0 Global $speed ; Create GUI $hMain_GUI = GUICreate("Draw Bot", 203, 93, 484, 261) $Paint_X = GUICtrlCreateButton("Paint", 8, 16, 49, 25) $DrawBtn = GUICtrlCreateButton("Draw", 8, 48, 49, 25) $Slider1 = GUICtrlCreateSlider(64, 24, 129, 17) GUICtrlSetLimit(-1, 45, 3) $Slider2 = GUICtrlCreateSlider(64, 48, 129, 17) GUICtrlSetLimit(-1, 45, 3) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE FileDelete(@ScriptDir & "\Rect.bmp") Exit Case $Paint_X GUISetState(@SW_HIDE, $hMain_GUI) _Region_Select() TrayTip("Painting Canvas", 'Press "F10" to stop', 5, 1) _Draw() GUISetState(@SW_SHOW, $hMain_GUI) Case $DrawBtn GUISetState(@SW_HIDE, $hMain_GUI) $imageFile = FileOpenDialog("Select Image", @WorkingDir, "Images (*.jpg;*.jpeg;*.gif;*.png;*.bmp)", 1) _Imagedraw() GUISetState(@SW_SHOW, $hMain_GUI) GUICtrlSetState($DrawBtn,$GUI_DISABLE) EndSwitch WEnd Func _Draw() ;Sleep(2000) For $y = $iY1 To $iY2 Step +GUICtrlRead($Slider1) For $x = $iX1 To $iX2 Step +GUICtrlRead($Slider2) BlockInput(1) MouseClick('LEFT', $x, $y, 1, 1) BlockInput(0) Sleep(1) If $drwstate Then ExitLoop Next If $drwstate Then ExitLoop Next $drwstate = False Return 1 EndFunc ;==>_Draw ; ------------- Func _Region_Select() Local $aMouse_Pos, $hMask, $hMaster_Mask, $iTemp Local $UserDLL = DllOpen("user32.dll") Global $hRectangle_GUI = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) _GUICreateInvRect($hRectangle_GUI, 0, 0, 1, 1) GUISetBkColor(0) WinSetTrans($hRectangle_GUI, "", 50) GUISetState(@SW_SHOW, $hRectangle_GUI) GUISetCursor(3, 1, $hRectangle_GUI) ; Wait until mouse button pressed While Not _IsPressed("01", $UserDLL) Sleep(10) WEnd ; Get first mouse position $aMouse_Pos = MouseGetPos() $iX1 = $aMouse_Pos[0] $iY1 = $aMouse_Pos[1] ; Draw rectangle while mouse button pressed While _IsPressed("01", $UserDLL) $aMouse_Pos = MouseGetPos() ; Set in correct order if required If $aMouse_Pos[0] < $iX1 Then $iX_Pos = $aMouse_Pos[0] $iWidth = $iX1 - $aMouse_Pos[0] Else $iX_Pos = $iX1 $iWidth = $aMouse_Pos[0] - $iX1 EndIf If $aMouse_Pos[1] < $iY1 Then $iY_Pos = $aMouse_Pos[1] $iHeight = $iY1 - $aMouse_Pos[1] Else $iY_Pos = $iY1 $iHeight = $aMouse_Pos[1] - $iY1 EndIf _GUICreateInvRect($hRectangle_GUI, $iX_Pos, $iY_Pos, $iWidth, $iHeight) Sleep(10) WEnd ; Get second mouse position $iX2 = $aMouse_Pos[0] $iY2 = $aMouse_Pos[1] ; Set in correct order if required If $iX2 < $iX1 Then $iTemp = $iX1 $iX1 = $iX2 $iX2 = $iTemp EndIf If $iY2 < $iY1 Then $iTemp = $iY1 $iY1 = $iY2 $iY2 = $iTemp EndIf GUIDelete($hRectangle_GUI) DllClose($UserDLL) EndFunc ;==>_Region_Select Func _GUICreateInvRect($hWnd, $iX, $iY, $iW, $iH) $hMask_1 = _WinAPI_CreateRectRgn(0, 0, @DesktopWidth, $iY) $hMask_2 = _WinAPI_CreateRectRgn(0, 0, $iX, @DesktopHeight) $hMask_3 = _WinAPI_CreateRectRgn($iX + $iW, 0, @DesktopWidth, @DesktopHeight) $hMask_4 = _WinAPI_CreateRectRgn(0, $iY + $iH, @DesktopWidth, @DesktopHeight) _WinAPI_CombineRgn($hMask_1, $hMask_1, $hMask_2, 2) _WinAPI_CombineRgn($hMask_1, $hMask_1, $hMask_3, 2) _WinAPI_CombineRgn($hMask_1, $hMask_1, $hMask_4, 2) _WinAPI_DeleteObject($hMask_2) _WinAPI_DeleteObject($hMask_3) _WinAPI_DeleteObject($hMask_4) _WinAPI_SetWindowRgn($hWnd, $hMask_1, 1) EndFunc ;==>_GUICreateInvRect ;//////////////////////////////////////////////// Func _Imagedraw() ;; Options dialog ;; $optGUI = GUICreate("Settings", 160, 270, -1, -1, $WS_CAPTION, BitOR($WS_EX_APPWINDOW, $WS_EX_TOOLWINDOW)) GUICtrlCreateGroup("Image processing", 5, 5, 150, 85) GUICtrlCreateLabel("Sensitivity (0~255):", 10, 28, 110, 15) $thresholdInput = GUICtrlCreateInput("100", 125, 25, 25, 20, $ES_NUMBER) GUICtrlCreateLabel("Width (px):", 10, 48, 110, 15) $widthInput = GUICtrlCreateInput("100", 125, 45, 25, 20, $ES_NUMBER) GUICtrlCreateLabel("Height (px):", 10, 68, 110, 15) $heightInput = GUICtrlCreateInput("100", 125, 65, 25, 20, $ES_NUMBER) GUICtrlCreateGroup("Drawing pattern", 5, 95, 150, 140) $horizontalRadio = GUICtrlCreateRadio("Horizontal", 10, 115, 110, 15) $verticalRadio = GUICtrlCreateRadio("Vertical", 10, 135, 110, 15) $diagonalRadio = GUICtrlCreateRadio("Diagonal", 10, 155, 110, 15) $rotateRadio = GUICtrlCreateRadio("Spiral", 10, 175, 110, 15) $scrambleRadio = GUICtrlCreateRadio("Random", 10, 195, 110, 15) GUICtrlSetState($diagonalRadio, $GUI_CHECKED) GUICtrlCreateLabel("Mouse speed (0~100):", 10, 213, 110, 15) $speedInput = GUICtrlCreateInput("0", 125, 210, 25, 20, $ES_NUMBER) $okBtn = GUICtrlCreateButton("Ok", 30, 245, 40, 20) $cancelBtn = GUICtrlCreateButton("Cancel", 80, 245, 50, 20) GUISetState() While 1 Switch (GUIGetMsg()) Case $GUI_EVENT_CLOSE Exit Case $cancelBtn Exit Case $okBtn $threshold = GUICtrlRead($thresholdInput) $width = GUICtrlRead($widthInput) $height = GUICtrlRead($heightInput) $speed = GUICtrlRead($speedInput) If (GUICtrlRead($horizontalRadio) == $GUI_CHECKED) Then $pathString = "45273618" ElseIf (GUICtrlRead($verticalRadio) == $GUI_CHECKED) Then $pathString = "27453618" ElseIf (GUICtrlRead($diagonalRadio) == $GUI_CHECKED) Then $pathString = "36184527" ElseIf (GUICtrlRead($rotateRadio) == $GUI_CHECKED) Then $pathString = "14678532" $rotate = 1 ElseIf (GUICtrlRead($scrambleRadio) == $GUI_CHECKED) Then $scramble = True EndIf GUIDelete($optGUI) ExitLoop EndSwitch WEnd ;; Processing dialog ;; $GUI = GUICreate("Processing image...", $width, $height + 20, -1, -1, $WS_CAPTION, BitOR($WS_EX_APPWINDOW, $WS_EX_TOOLWINDOW)) GUISetBkColor(0xffffff) $imageBox = GUICtrlCreatePic($imageFile, 0, 0, $width, $height) $progress = GUICtrlCreateProgress(0, $height, $width, 20) GUISetState() ;; Get image pixels ;; $dc = _WinAPI_GetDC($GUI) $memDc = _WinAPI_CreateCompatibleDC($dc) $bitmap = _WinAPI_CreateCompatibleBitmap($dc, $width, $height) _WinAPI_SelectObject($memDc, $bitmap) _WinAPI_BitBlt($memDc, 0, 0, $width, $height, $dc, 0, 0, $SRCCOPY) $bits = DllStructCreate("dword[" & ($width * $height) & "]") DllCall("gdi32", "int", "GetBitmapBits", "ptr", $bitmap, "int", ($width * $height * 4), "ptr", DllStructGetPtr($bits)) GUICtrlDelete($imageBox) ;; Process the pixels ;; Dim $pixels[$width][$height] For $y = 0 To ($height - 1) For $x = 0 To ($width - 1) $index = ($y * $width) + $x $color = DllStructGetData($bits, 1, $index) $red = _ColorGetBlue($color) $green = _ColorGetGreen($color) $blue = _ColorGetRed($color) $shade = ($red + $green + $blue) / 3 If ($shade > $threshold) Then $color = 0xffffff $pixels[$x][$y] = 0 Else $color = 0 $pixels[$x][$y] = 1 EndIf DllStructSetData($bits, 1, $color, $index) Next DllCall("gdi32", "int", "SetBitmapBits", "ptr", $bitmap, "int", ($width * $height * 4), "ptr", DllStructGetPtr($bits)) _WinAPI_BitBlt($dc, 0, 0, $width, $height, $memDc, 0, 0, $SRCCOPY) GUICtrlSetData($progress, ($y * 100) / $height) Next _WinAPI_ReleaseDC($GUI, $dc) GUIRegisterMsg($WM_PAINT, "OnPaint") ;; Ready to draw ;; TrayTip("Image Ready", "Press 'F9' to print at mouse position, 'F10' to quit.", 10) HotKeySet("{F9}", "Draw") HotKeySet("{F10}", "Quit") Return 1 EndFunc ;==>_Imagedraw Func OnPaint($hwndGUI, $msgID, $wParam, $lParam) Local $paintStruct = DllStructCreate("hwnd hdc;int fErase;dword rcPaint[4];int fRestore;int fIncUpdate;byte rgbReserved[32]") $dc = DllCall("user32", "hwnd", "BeginPaint", "hwnd", $hwndGUI, "ptr", DllStructGetPtr($paintStruct)) $dc = $dc[0] _WinAPI_BitBlt($dc, 0, 0, $width, $height, $memDc, 0, 0, $SRCCOPY) DllCall("user32", "hwnd", "EndPaint", "hwnd", $hwndGUI, "ptr", DllStructGetPtr($paintStruct)) Return $GUI_RUNDEFMSG EndFunc ;==>OnPaint Func Draw() $mouseCenter = MouseGetPos() $x0 = $mouseCenter[0] - ($width / 2) $y0 = $mouseCenter[1] - ($height / 2) ;; Draw all the areas ;; $stack = CreateStack(1000) For $y = 0 To ($height - 1) For $x = 0 To ($width - 1) If ($pixels[$x][$y] == 1) Then BlockInput(1) MouseMove($x + $x0, $y + $y0, $speed) MouseDown("primary") DrawArea($stack, $x, $y, $x0, $y0) MouseUp("primary") BlockInput(0) Else EndIf If $drwstate Then ExitLoop Next If $drwstate Then ExitLoop Next $drwstate = False ;; Reset the pixels statuses ;; For $y = 0 To ($height - 1) Step 1 For $x = 0 To ($width - 1) Step 1 If ($pixels[$x][$y] == 2) Then $pixels[$x][$y] = 1 EndIf Next Next EndFunc ;==>Draw Func DrawArea(ByRef $stack, $x, $y, $x0, $y0) Local $path[8] Local $continue $path = StringSplit($pathString, "") While 1 MouseMove($x + $x0, $y + $y0, $speed) $pixels[$x][$y] = 2 If ($scramble) Then ScramblePath($path) If ($rotate > 0) Then RotatePath($path, $rotate) ;;;;;;;;;;;;;;;;;;; ;; +---+---+---+ ;; ;; | 1 | 2 | 3 | ;; ;; +---+---+---+ ;; ;; | 4 | | 5 | ;; ;; +---+---+---+ ;; ;; | 6 | 7 | 8 | ;; ;; +---+---+---+ ;; ;;;;;;;;;;;;;;;;;;; $continue = False For $i = 0 To 7 Switch ($path[$i]) Case 1 If (($x > 0) And ($y > 0)) Then If ($pixels[$x - 1][$y - 1] == 1) Then Push($stack, $x, $y) $x -= 1 $y -= 1 $continue = True ExitLoop EndIf EndIf Case 2 If ($y > 0) Then If ($pixels[$x][$y - 1] == 1) Then Push($stack, $x, $y) $y -= 1 $continue = True ExitLoop EndIf EndIf Case 3 If (($x > 0) And ($y < 0)) Then If ($pixels[$x + 1][$y - 1] == 1) Then Push($stack, $x, $y) $x += 1 $y -= 1 $continue = True ExitLoop EndIf EndIf Case 4 If ($x > 0) Then If ($pixels[$x - 1][$y] == 1) Then Push($stack, $x, $y) $x -= 1 $continue = True ExitLoop EndIf EndIf Case 5 If ($x < ($width - 1)) Then If ($pixels[$x + 1][$y] == 1) Then Push($stack, $x, $y) $x += 1 $continue = True ExitLoop EndIf EndIf Case 6 If (($x < 0) And ($y > 0)) Then If ($pixels[$x - 1][$y + 1] == 1) Then Push($stack, $x, $y) $x -= 1 $y += 1 $continue = True ExitLoop EndIf EndIf Case 7 If ($y < ($height - 1)) Then If ($pixels[$x][$y + 1] == 1) Then Push($stack, $x, $y) $y += 1 $continue = True ExitLoop EndIf EndIf Case 8 If (($x < ($width - 1)) And ($y < ($height - 1))) Then If ($pixels[$x + 1][$y + 1] == 1) Then Push($stack, $x, $y) $x += 1 $y += 1 $continue = True ExitLoop EndIf EndIf EndSwitch Next If ($continue) Then ContinueLoop If (Not Pop($stack, $x, $y)) Then ExitLoop WEnd EndFunc ;==>DrawArea Func ScramblePath(ByRef $path) Local $table = "12345678" Local $newPath[8] For $i = 8 To 1 Step -1 $next = StringMid($table, Random(1, $i, 1), 1) $newPath[$i - 1] = Number($next) $table = StringReplace($table, $next, "") Next $path = $newPath EndFunc ;==>ScramblePath Func RotatePath(ByRef $path, $places) If ($places == 0) Then Return $path Else For $i = 1 To Abs($places) $temp = $path[7] $path[7] = $path[6] $path[6] = $path[5] $path[5] = $path[4] $path[4] = $path[3] $path[3] = $path[2] $path[2] = $path[1] $path[1] = $path[0] $path[0] = $temp Next EndIf EndFunc ;==>RotatePath Func CreateStack($size) Dim $stack[$size + 1][2] $stack[0][0] = 0 $stack[0][1] = $size Return $stack EndFunc ;==>CreateStack Func Push(ByRef $stack, $x, $y) $stack[0][0] += 1 If ($stack[0][0] > $stack[0][1]) Then $stack[0][1] += 1000 ReDim $stack[$stack[0][1] + 1][2] EndIf $stack[$stack[0][0]][0] = $x $stack[$stack[0][0]][1] = $y EndFunc ;==>Push Func Pop(ByRef $stack, ByRef $x, ByRef $y) If ($stack[0][0] < 1) Then Return False EndIf $x = $stack[$stack[0][0]][0] $y = $stack[$stack[0][0]][1] $stack[0][0] -= 1 Return True EndFunc ;==>Pop Func Nothing() EndFunc ;==>Nothing Func Quit() BlockInput(0) MouseUp("primary") $drwstate = True TrayTip("Operation Halt","All Bot Operations Have Benn Halted",3,1)EndFunc ;==>Quit Edited July 25, 2011 by THAT1ANONYMOUSEDUDE
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