Sign in to follow this  
Followers 0
Oxin8

SprayPaint

8 posts in this topic

#1 ·  Posted (edited)

Last night I wanted to make something fun that drew pixels onscreen and SprayPaint is the result of that. Open paint and then draw an image of any size(but make note of it) then run SprayPaint.au3. It prompts for the width, height, and file name, then it activates the paint window and reads the pixels. Then it writes an autoit script with the specified filename. The script also has an $ignorecolor (defaultly white) so it doesn't draw any pixels of that color and it looks better. If you set it to -1 it should draw everything. After it indicates that it's done, you can press ctrl+s to spray or ctrl+e to exit. The resulting autoit script draws the image at the current mouse coords every 200 milliseconds. I've included an example result so you can see. (btw, requires beta)

EDIT: ctrl+e quits the second script

For the lazy people that won't download just to see a script:

Opt("PixelCoordMode",0)
Opt("WinTitleMatchMode",2)
Opt("ColorMode",1)

$width = InputBox("SprayPaint", "Width:")
$height = InputBox("SprayPaint", "Height:")
$fname = InputBox("SprayPaint", "File Name:")
$ignorecolor=0xFFFFFF
Dim $spray[$width][$height]
WinActivate("- Paint")
WinWaitActive("- Paint")
For $x = 65 to (64 + $width) 
    For $y = 47 to (46 + $height)
    $spray[$x-65][$y-47] = PixelGetColor($x,$y)
    Next
Next
MsgBox(0,"SprayPaint","Spray Retrieved")

$myfile = FileOpen($fname, 2)

FileWrite($myfile, 'Opt("ColorMode",1)'& @CRLF)
FileWrite($myfile, 'HotKeySet("^e","quit")'& @CRLF)
FileWrite($myfile, "While 1" & @CRLF & "$pos= MouseGetPos()" & @CRLF & "pict($pos[0],$pos[1])" & @CRLF & _
    "Sleep(200)" & @CRLF & "WEnd" & @CRLF)
FileWrite($myfile, 'Func quit()'& @CRLF & "Exit" & @CRLF & "EndFunc" & @CRLF)
FileWrite($myfile, 'Func drawpix($dc,$x,$y,$color)' & @CRLF & _
    'DllCall ("gdi32.dll", "long", "SetPixel", "long", $dc[0], "long", $x, "long", $y, "long", $color)' _
     & @CRLF & "EndFunc" & @CRLF)
FileWrite($myfile, "Func pict($x,$y)" & @CRLF & '$dc= DllCall ("user32.dll", "int", "GetDC", "hwnd", "")' & @CRLF)
For $x = 0 to ($width-1)
    For $y = 0 to ($height-1)
    If $spray[$x][$y] <> $ignorecolor Then FileWrite ( $myfile, "drawpix($dc,$x+" & $x & ",$y+" & $y & ",0x" & hex($spray[$x][$y]) & ")" & @CRLF)
    Next
Next
FileWrite($myfile,'DllCall ("user32.dll", "int", "ReleaseDC", "hwnd", 0,  "int", $dc[0])' & @CRLF & "EndFunc")
FileClose($myfile)
MsgBox(0,"SprayPaint","Spray Written To " & $fname)

waiting()

Func waiting()
HotKeySet("^s","spray")
HotKeySet("^e","quittime")
While 1
   Sleep(50)
WEnd
EndFunc

Func quittime()
   Exit
EndFunc

Func spray()
    $dc= DllCall ("user32.dll", "int", "GetDC", "hwnd", "")
    $pos= MouseGetPos ()
    For $x = 0 to ($width-1)
    For $y = 0 to ($height-1)
        If $spray[$x][$y] <> $ignorecolor Then DllCall ("gdi32.dll", "long", "SetPixel", "long", $dc[0], "long", $pos[0] + $x, "long", $pos[1] + $y, "long", "0x" & hex($spray[$x][$y]))
    Next
    Next
    DllCall ("user32.dll", "int", "ReleaseDC", "hwnd", 0,  "int", $dc[0])
EndFunc

hearts.au3

spraypaint.au3

Edited by Oxin8

Share this post


Link to post
Share on other sites



nice :lmao:


AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!

Share this post


Link to post
Share on other sites

wow thats fun =)


[font="Verdana"]In work:[list=1][*]InstallIt[*]New version of SpaceWar[/list] [/font]

Share this post


Link to post
Share on other sites

A person can have some fun with this. It may be worth building in a hotkey to stop the second script.

:lmao:



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

funny :o


-jaenster

Share this post


Link to post
Share on other sites

How it works ???

I think im doing anything wrong...

I've started Spraypaint filled in the inputboxes and then ??


Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

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