Jump to content
Sign in to follow this  
CyNDeR

Random Painter v0.6 (Updated 11/20/07)

Recommended Posts

CyNDeR

I was bored the other night and decided to make this. It opens MsPaint and randomly draws using various paint functions.

Big thanks to zfisherdrums for pointing out the registry keys for the width and height of the drawing area.

Version 0.6 Uses airbrush with all 3 sizes, paintbrush using all 12 styles, lines using all 5 sizes, and rectangles, rounded rectangles, and ellipses.

Note: The shapes and lines can only be drawn with the window maximized/in focus. If its not, it will just use the other functions.

V0.6

HotKeySet("{ESC}", "End")
Run("mspaint.exe")
WinWaitActive("[CLASS:MSPaintApp]")
WinSetState("[CLASS:MSPaintApp]", "", @SW_MINIMIZE)
Global $Width
Global $Height
Global $Pos
$Pos = ControlGetPos("[CLASS:MSPaintApp]", "", "[CLASS:Afx:1000000:8]")
$Width = RegRead( "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Applets\Paint\View", "BMPWidth" )
$Height = RegRead( "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Applets\Paint\View", "BMPHeight" )
Opt("MouseCoordMode", 2)
Setup()
While 1
    $DrawType = Random(1, 4, 1)
    Switch $DrawType
        Case 1
            AirBrush()
        Case 2
            PaintBrush()
        Case 3
            ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 16, 141)
            ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 28, 219)
            Shapes()
        Case 4
            Lines()
    EndSwitch
WEnd
Func Setup()
    ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 43, 42)
    ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 41, 15)
    ControlClick("[CLASS:MSPaintApp]", "", "[CLASS:Afx:1000000:8]")
EndFunc   ;==>Setup
Func AirBrush()
    PickColor()
    ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 18, 116)
    PickAirBrush()
    $Rnd = Random(2, 500, 1)
    For $i = 1 To $Rnd
        $x = Random(5, $Pos[2] - 5, 1)
        $y = Random(5, $Pos[3] - 5, 1)
        ControlClick("[CLASS:MSPaintApp]", "", "[CLASS:Afx:1000000:8]", "left", 1, $x, $y)
    Next
EndFunc   ;==>AirBrush
Func PaintBrush()
    PickColor()
    ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 41, 90)
    PickPaintBrush()
    $Rnd = Random(2, 250, 1)
    For $i = 1 To $Rnd
        $x = Random($Pos[0] + 5, $Pos[0] + $Width - 5, 1)
        $y = Random($Pos[1] + 5, $Pos[1] + $Height - 5, 1)
        ControlClick("[CLASS:MSPaintApp]", "", "[CLASS:Afx:1000000:8]", "left", 1, $x, $y)
    Next
EndFunc   ;==>PaintBrush
Func Shapes()
    $WindowState = WinGetState("[CLASS:MSPaintApp]")
    $Rnd = Random(1, 15)
    For $i = 1 To $Rnd
        If BitAND($WindowState, 8) Then
            PickColor()
            PickShape()
            $X1 = Random($Pos[0] + 5, $Pos[0] + $Pos[2] - 5, 1)
            $Y1 = Random($Pos[1] + 5, $Pos[1] + $Pos[3] - 5, 1)
            $X2 = Random($Pos[0] + 5, $Pos[0] + $Pos[2] - 5, 1)
            $Y2 = Random($Pos[1] + 5, $Pos[1] + $Pos[3] - 5, 1)
            MouseClickDrag("left", $X1, $Y1, $X2, $Y2, 1)
        EndIf
    Next
EndFunc   ;==>Shapes
Func Lines()
    $Rnd = Random(1, 15)
    For $i = 1 To $Rnd
        $WindowState = WinGetState("[CLASS:MSPaintApp]")
        If BitAND($WindowState, 8) Then
            ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 16, 141)
            PickColor()
            PickLineType()
            $X1 = Random($Pos[0] + 5, $Pos[0] + $Width - 5, 1)
            $Y1 = Random($Pos[1] + 5, $Pos[1] + $Height - 5, 1)
            $X2 = Random($Pos[0] + 5, $Pos[0] + $Width - 5, 1)
            $Y2 = Random($Pos[1] + 5, $Pos[1] + $Height - 5, 1)
            MouseClickDrag("left", $X1, $Y1, $X2, $Y2, 1)
        EndIf
    Next
EndFunc   ;==>Lines
Func PickColor()
    $color = Random(1, 28, 1)
    Switch $color
        Case 1
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 41, 15)
        Case 2
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 56, 15)
        Case 3
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 72, 15)
        Case 4
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 88, 15)
        Case 5
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 104, 15)
        Case 6
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 120, 15)
        Case 7
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 136, 15)
        Case 8
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 152, 15)
        Case 9
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 169, 15)
        Case 10
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 185, 15)
        Case 11
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 200, 15)
        Case 12
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 216, 15)
        Case 13
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 232, 15)
        Case 14
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 248, 15)
        Case 15
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 41, 32)
        Case 16
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 56, 32)
        Case 17
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 72, 32)
        Case 18
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 88, 32)
        Case 19
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 104, 32)
        Case 20
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 120, 32)
        Case 21
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 136, 32)
        Case 22
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 152, 32)
        Case 23
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 169, 32)
        Case 24
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 185, 32)
        Case 25
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 200, 32)
        Case 26
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 216, 32)
        Case 27
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 232, 32)
        Case 28
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 248, 32)
    EndSwitch
EndFunc   ;==>PickColor
Func PickShape()
    $Shape = Random(1, 3, 1)
    Switch $Shape
        Case 1
            ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 17, 166)
        Case 2
            ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 17, 190)
        Case 3
            ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 41, 191)
    EndSwitch
EndFunc   ;==>PickShape
Func PickPaintBrush()
    $Brush = Random(1, 3, 1)
    Switch $Brush
        Case 1
            ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 19, 227)
        Case 2
            ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 39, 227)
        Case 3
            ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 30, 259)
    EndSwitch
EndFunc   ;==>PickPaintBrush
Func PickAirBrush()
    $Brush = Random(1, 12, 1)
    Switch $Brush
        Case 1
            ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 16, 218)
        Case 2
            ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 28, 218)
        Case 3
            ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 42, 218)
        Case 4
            ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 16, 234)
        Case 5
            ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 28, 234)
        Case 6
            ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 42, 234)
        Case 7
            ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 16, 250)
        Case 8
            ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 28, 250)
        Case 9
            ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 42, 250)
        Case 10
            ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 16, 265)
        Case 11
            ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 28, 265)
        Case 12
            ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 42, 265)
    EndSwitch
EndFunc   ;==>PickAirBrush
Func PickLineType()
    $LineType = Random(1, 5, 1)
    Switch $LineType
        Case 1
            ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 28, 219)
        Case 2
            ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 28, 230)
        Case 3
            ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 28, 241)
        Case 4
            ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 28, 254)
        Case 5
            ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 28, 265)
    EndSwitch
EndFunc   ;==>PickLineType
Func End()
    Exit
EndFunc   ;==>End
Edited by CyNDeR

My scripts: Random Painter

Share this post


Link to post
Share on other sites
JustinReno

No one is going to like it unless you put controlclick in there. And resulution wouldn't matter if you used controlclick.

Share this post


Link to post
Share on other sites
Spudsz

You dont need exact resolution, just make sure the window is in the top left and the colours line up with the mouse co-ordinates

Fun little script <_< i enjoyed it

Share this post


Link to post
Share on other sites
AlmarM

The only thing the script does is... Making the paint field BLACK... Then its trying to make something... with BLACK...

It wont do antything unless making it black and trying to make something with black <_<


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
jvanegmond

The only thing the script does is... Making the paint field BLACK... Then its trying to make something... with BLACK...

It wont do antything unless making it black and trying to make something with black <_<

Probably because you didn't drag the taskbar up far enough, so that it could select a different color.

Share this post


Link to post
Share on other sites
MrCreatoR

It opens Paint and randomly paints using the airbrush. It uses all 3 brush styles and all 28 colors. Must be run in 1024x768 and when i made it i forgot that i have a double size task bar

For me it will never work, my paint have a diferent title (on russian), so you should use window CLASS not title.

And resolution realy not matter, use mouse coords mode for the client area of the paint <_<

And also after each click you should activate the paint again (make a function for the procedure), because user can switch to another window - or just BlockInput while the script is painting.

P.S

Nice idea.


 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites
JustinReno

Probably because you didn't drag the taskbar up far enough, so that it could select a different color.

Mine did that too, and I set up the task bar right. It selects the paint can instead of the tool it wants.

Share this post


Link to post
Share on other sites
CyNDeR

Yeah, this was just a little script i made because i was bored.. and it just so happens i'm bored again, so ill probably do those changes tonight. Also, after i posted this, i had another idea. Replace the Draw() Function with this:

Func Draw()
    $Rnd = Random(2, 10, 1)
    For $i = 1 To $Rnd
        $x1 = Random(60, 1002, 1)
        $y1 = Random(52, 612, 1)
        $x2 = Random(60, 1002, 1)
        $y2 = Random(52, 612, 1)
        MouseClickDrag("left", $x1, $y1, $x2, $y2, 5)
    Next
EndFunc   ;==>Draw

I think it looks cooler this way. :P I might also add both function together and make it do the dots and lines, what do you guys think?

Edited by CyNDeR

My scripts: Random Painter

Share this post


Link to post
Share on other sites
CyNDeR

Alright, next version is done. This one works minimized, uses CLASS to find the window instead of title, and uses ControlClick() so there is no resolution issues. This one should work for almost everyone. Thanks go to Richard Robertson for helping me get it to work while minimized.

HotKeySet("{ESC}", "End")
Run("mspaint.exe")
WinWaitActive("[CLASS:MSPaintApp]")
WinSetState("[CLASS:MSPaintApp]", "", @SW_MINIMIZE)
Setup()
While 1
    PickBrush()
    PickColor()
    Draw()
WEnd
Func Setup()
    ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 43, 42)
    ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 41, 15)
    ControlClick("[CLASS:MSPaintApp]", "", "[CLASS:Afx:1000000:8]")
    ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 18, 116)
EndFunc   ;==>Setup
Func PickBrush()
    $Brush = Random(1, 3, 1)
    Switch $Brush
        Case 1
            ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 19, 227)
        Case 2
            ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 39, 227)
        Case 3
            ControlClick("[CLASS:MSPaintApp]", "", 59415, "left", 1, 30, 259)
    EndSwitch
EndFunc   ;==>PickBrush
Func PickColor()
    $color = Random(1, 28, 1)
    Switch $color
        Case 1
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 41, 15)
        Case 2
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 56, 15)
        Case 3
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 72, 15)
        Case 4
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 88, 15)
        Case 5
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 104, 15)
        Case 6
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 120, 15)
        Case 7
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 136, 15)
        Case 8
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 152, 15)
        Case 9
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 169, 15)
        Case 10
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 185, 15)
        Case 11
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 200, 15)
        Case 12
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 216, 15)
        Case 13
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 232, 15)
        Case 14
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 248, 15)
        Case 15
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 41, 32)
        Case 16
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 56, 32)
        Case 17
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 72, 32)
        Case 18
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 88, 32)
        Case 19
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 104, 32)
        Case 20
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 120, 32)
        Case 21
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 136, 32)
        Case 22
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 152, 32)
        Case 23
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 169, 32)
        Case 24
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 185, 32)
        Case 25
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 200, 32)
        Case 26
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 216, 32)
        Case 27
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 232, 32)
        Case 28
            ControlClick("[CLASS:MSPaintApp]", "", 59416, "left", 1, 248, 32)
    EndSwitch
EndFunc   ;==>PickColor
Func Draw()
    $Rnd = Random(2, 500, 1)
    For $i = 1 To $Rnd
        $x = Random(3, 960, 1)
        $y = Random(3, 608, 1)
        ControlClick("[CLASS:MSPaintApp]", "", "[CLASS:Afx:1000000:8]", "left", 1, $x, $y)
    Next
EndFunc   ;==>Draw
Func End()
    Exit
EndFunc   ;==>End

My scripts: Random Painter

Share this post


Link to post
Share on other sites
AlmarM

My revolution is:

1280 - 1024

So how far sould I drag the taskbar up ??

-AlmarM

Edited by AlmarM

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
Generator

My revolution is:

1280 - 1024

So how far sould I drag the taskbar up ??

-AlmarM

You don't need to, just run the script in his last post.

Share this post


Link to post
Share on other sites
CyNDeR

Nice work! I ended up with a bunch of small designs of color and two simple straight lines... I'm not sure why there were two lines but it still looked cool...

It was most likely from you moving your mouse over the painting area. For some reason it draws when your mouse is over it.


My scripts: Random Painter

Share this post


Link to post
Share on other sites
JustinReno

I thought this was cool, it made some lines because I accidently moved the mouse, but it looks cool. I like the black background, the bright white doesn't hurt your eyes.

NOTE: This JPG image washed out a LOT of the BMP color, so when you use it, there is a LOT more color. :P

Posted Image

Share this post


Link to post
Share on other sites
CyNDeR

Yeah, the BMP's look alot better. I think its pretty cool so far. Anyone have any ideas or feature requests?


My scripts: Random Painter

Share this post


Link to post
Share on other sites
jvanegmond

Yeah, the BMP's look alot better. I think its pretty cool so far. Anyone have any ideas or feature requests?

Maybe you could make it draw random shapes instead of random pixels.

After that, go on and draw random figures.

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  

×