Sign in to follow this  
Followers 0
Szhlopp

Facebook Graffiti

4 posts in this topic

Hey all

Here is something I had written a long time ago. It worked but was VERY slow. I recently had a few ideas to improve it's speed and it seems to work very well on my pc.

Well enough of that... Let's get onto the application :D

Facebook Paint draws a 'clone' of the selelected image. The clone isn't an exact copy, it's more of an artistic spotted painting. Still makes a very cool effect.

Setup Guide:

*** Facebook paint by Szhlopp ***
           Graffiti Draw Application (Tested on Vista/IE7)


Step 1) Create an image that is 510x270 (Graffiti canvas size). 
   -Anything larger than 510x270 will be cutoff.
   -Whitespace is ignored. 0xFFFFFF is effectively transparent.

Step 2) Color in the entire canvas with 0x000000 (Black)
   -The opacity MUST be 100%
   - Make sure the upper left corner is completely filled in with black

Step 3) Run the program and place your mouse close the upper left part of the canvas, press F9
   - Program auto-detects the borders based on the the least X,Y coordinate of black pixels.

Step 4) Select an image to draw

Step 5) While the image is being loaded into memory, sorted and being setup, Fill in the canvas with white
   - Opacity 100%, color 0xFFFFFF

Step 6) Ready to start!

'1' - Start the application
'2' - Any point during the draw will cancel and quit the script


*Few fast tips*
- Make sure Facebook is the active window before you start ('1')
- Make sure there aren't any other windows overlapping IE
- This ONLY works if the graffiti paint window is full size (No scrollbars to move around the image. Don't draw from the 'home' page)
- If the progran isn't detecting the black, make sure the opacity slider IS all the way to the right and that your color IS #000000

Enjoy!

Script:

#include <misc.au3>
#include <GDIplus.au3>
#include <color.au3>
#include <Array.au3>
;

Global $TopLeft[2] ; X Y
Global $TopRight[2]
Global $BottomLeft[2]
Global $BottomRight[2]
Global $ColorIcon[2]
Global $PixelData[510 * 270]; Holds every pixel
Global $EndOfPixel = 137699
Global $LastColor = 99999999999999999
Global $hWndWindow = 0

Global $MouseClickColor = 50; - 50
Global $MouseClickPaint = 85; Time the mouse is held down - 85
Global $PixelWidth = 6; - 6
Global $PixelAllow = 2000 ; Difference in pixel before change - 2000


; 510x270

Opt("SendKeyDelay", 10)
Opt("SendKeyDownDelay", 15)
Opt("MouseClickDownDelay", $MouseClickPaint)
Opt("MouseClickDelay", 25)

$ExitLoop = 1
TrayTip("Mouse", "Press F9 to start auto-detect." & @CRLF & "(Please read the setup guide to get started.)", 30)
While $ExitLoop = 1
    Sleep(50)
    If _IsPressed(78) Then ; F9
        $mousePos = MouseGetPos()
        If Not PixelGetColor($mousePos[0], $mousePos[1]) = 0 Then
            MsgBox(0, "Error", "Mouse is not over the upper left black pixel")
        Else
            Local $PixelCheck = 0
            Local $X = $mousePos[0]
            Local $Y = $mousePos[1]

            ; Loop for X
            While $PixelCheck <> 16777215
                $X -= 1
                $PixelCheck = PixelGetColor($X, $Y)
            WEnd
            $X += 1
            $TopLeft[0] = $X
            $PixelCheck = 0

            ; Loop for Y
            While $PixelCheck <> 16777215
                $Y -= 1
                $PixelCheck = PixelGetColor($X, $Y)
            WEnd
            $Y += 1
            $TopLeft[1] = $Y

            ; Sets other coordinates
            $TopRight[0] = $TopLeft[0] + 509
            $TopRight[1] = $TopLeft[1]
            $BottomLeft[0] = $TopLeft[0]
            $BottomLeft[1] = $TopLeft[1] + 269
            $BottomRight[0] = $TopRight[0]
            $BottomRight[1] = $BottomLeft[1]
            ;MsgBox(0, "", $TopLeft[0] & "," & $TopLeft[1] & "|" & $TopRight[0] & "," & $TopRight[1] & "|" & $BottomLeft[0] & "," & $BottomLeft[1] & "|" & $BottomRight[0] & "," & $BottomRight[1])
            MouseMove($TopRight[0], $TopRight[1])
            MouseMove($BottomRight[0], $BottomRight[1])
            MouseMove($BottomLeft[0], $BottomLeft[1])
            MouseMove($TopLeft[0], $TopLeft[1])
            $ExitLoop = 0
        EndIf


        While _IsPressed(78)
            Sleep(20)
        WEnd

    EndIf


WEnd

; Set the color icon
$ColorIcon[0] = $BottomLeft[0] + 98
$ColorIcon[1] = $BottomLeft[1] + 45

;Color set
_ChangeColorEx("FFFFFF")

;Get location
TrayTip("Image", "Please select the image(Remember it HAS to be 510x270)", 30)
$FOD = FileOpenDialog("Image", @DesktopDir, "JPG (*.jpg)", 3)
If @error = 1 Then
    Exit
EndIf

$hMainGUI = GUICreate("Loading Data... Please wait", 510, 270, @DesktopWidth * .2, @DesktopHeight * .5)
GUISetState(@SW_SHOW)
TrayTip("Loading", "Loading image into memory. Please wait...", 15)


; Start GDI
_GDIPlus_Startup()
$hGraphics = _GDIPlus_GraphicsCreateFromHWND($hMainGUI)
$hImage = _GDIPlus_ImageLoadFromFile($FOD)
$iImageWidth = _GDIPlus_ImageGetWidth($hImage)
$iImageHeight = _GDIPlus_ImageGetHeight($hImage)
_GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, $iImageWidth, $iImageHeight)
$dc = _GDIPlus_GraphicsGetDC($hGraphics)
$dll = DllOpen("Gdi32.dll")


; Load into memory
$PixelDataInt = 0
For $w = 0 To 510 - 1
    For $h = 0 To 270 - 1
        $temp = DllCall($dll, "int", "GetPixel", "ptr", $dc, "int", $w, "int", $h)
        $R = _ColorGetRed($temp[0])
        $G = _ColorGetGreen($temp[0])
        $B = _ColorGetBlue($temp[0])
        $PixelData[$PixelDataInt] =  Hex($R + 256 * $G + 256 * 256 * $B,6) & "~" & $w & "," & $h
        $PixelDataInt += 1
    Next
Next
_GDIPlus_GraphicsReleaseDC($hGraphics, $dc)
DllClose($dll)

; Hide GUI
GUISetState(@SW_HIDE, $hMainGUI)

;Sort
TrayTip("Sorting", "Started the pixel sort... Please wait", 30)
_ArraySort($PixelData)

;Don't write FFFFFF
TrayTip("Final process", "Setting the end point... Please wait", 30)
For $I = 0 To UBound($PixelData) - 1
    $SS = StringSplit($PixelData[$I], "~")
    If $SS[1] = "FFFFFF" Then
        $EndOfPixel = $I
        ExitLoop
    EndIf
Next

;Ready
TrayTip("Ready", "Ready to start. Press 1 when ready to begin, 2 to exit the app at any point. (Make sure facebook is the active window!)", 15)

;Wait to start
While 1
    Sleep(20)
    If _IsPressed(31) Then ; 1 Start
        While _IsPressed(31)
            Sleep(50)
        WEnd

        ;Width 3
        MouseClick("Primary", $ColorIcon[0] + 50, $ColorIcon[1] - 10)

        ;Opacity set
        MouseClick("Primary", $ColorIcon[0] + 87, $ColorIcon[1] + 33)

        StartDrawEx()
    EndIf
WEnd

Func StartDrawEx()
    TrayTip("Starting", "Starting in 5 seconds...", 30)
    Sleep(5000)
    $Total = $EndOfPixel
    For $I = 0 To $EndOfPixel Step $PixelWidth
        If $PixelData[$I] <> "FFFFFF" Then
            $SS = StringSplit($PixelData[$I], "~")
            If $SS[0] = 2 Then
                $XY = StringSplit($SS[2], ",")

                ; Color difference
                $ColorDiff = Abs(Dec($LastColor) - Dec($SS[1]))
                If $ColorDiff > $PixelAllow Then

                    ;Status
                    TrayTip("", "", 1)
                    TrayTip("Status", $I & "/" & $Total & " complete. " & Round($I / $Total, 4) * 100 & "%", 15)

                    ;Color change
                    _ChangeColorEx($SS[1])
                EndIf

                ; Set the last color
                $LastColor = $SS[1]

                ;Paint it
                _PaintAtEx($XY[1], $XY[2])

                If _IsPressed(32) Then ; 2 Stop
                    Exit
                    While _IsPressed(32)
                        Sleep(50)
                    WEnd
                EndIf
            EndIf
        EndIf

    Next
EndFunc



Func _ChangeColorEx($Color)
    $Mpos = MouseGetPos()
    $Wait = 1
    While $Wait >= 1 And $Wait < 5
        $Mposcheck = MouseGetPos()
        If $Mposcheck[0] = $Mpos[0] And $Mposcheck[1] = $Mpos[1] Then
            $Wait += 1
        Else
            $Wait = 0
        EndIf
        Sleep(100)
    WEnd

    Opt("MouseClickDownDelay", $MouseClickColor)
    Sleep(50)
    MouseClick("Primary", $ColorIcon[0], $ColorIcon[1], 1, 0)
    Sleep(200)
    Send("^A")
    Sleep(100)
    Send("{Backspace}")
    Sleep(100)
    Send($Color)
    Sleep(150)
    Send("{enter}")
    Sleep(50)
    Opt("MouseClickDownDelay", $MouseClickPaint)
    Return 0
EndFunc

Func _PaintAtEx($x, $y)
    MouseMove($x + $TopLeft[0], $y + $TopLeft[1], 0)
    ;Sleep(15)
    MouseDown("Primary")
    Sleep($MouseClickPaint)
    MouseUp("Primary")
EndFunc

If anyone has improvements to the script feel free to post them here :D

Szhlopp

Share this post


Link to post
Share on other sites



this almost works... everything loads up fine but it doesnt change brush sizes or colors does anyone know why? or how to fix?

Share this post


Link to post
Share on other sites

Can you or anyone update this for 2011? Or what coords I should change?

Share this post


Link to post
Share on other sites

that stupid ! do you think sometime you want stop it and what do you can to stop that fucking program ???

damn !

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0