SRL Archive - Other Scripts

Paint Include


botmaster

2006-11-28 16:13:59

I know, it might sound like a waste of time (well, it actually is :D ), but I don't care, I made an include/script mix for Micr0s0f7 paint. I have no sample script for the include yet (although in the comments at the top it say so), it's still in the works of being scripted and lacks some features I've wanted to add, and you have to convert into an include yourself.

It probably sucks real badly, its still in its beta stages and some procedures may just… errm… mess up. Please post any bugs you may encounter, so that the next release will be a little more advanced! If you like it I'm gonna continue and add full menu support in the next version!

program MSpaintArtist;

{======================[Description and Release Notes]=========================}
{ Artist V 0.5 }
{==============================================================================}
{ }
{ Artist is a freely distributed script according to the GNU public license as }
{ of 1991. If you bought this program or the script, you have been scammed. }
{ }
{==================================[About]=====================================}
{ }
{ This program features tools that allow a scripter to interact with the UI of }
{ Microsoft Paint. It contains a commented surface of drawing tools, each one }
{ of them can perform specific tasks. Use this tool at leisure to create }
{ drawings that ordinairly, you couldn't draw such as gradients, patterns, }
{ graphs, and other things. Or just simply impress your friends by using this. }
{ }
{ Hint: You can easily convert this file to an include, which in can be }
{ practical in certain cases. }
{ }
{=============================[How to use this]================================}
{ }
{ Set your screen resolution to 1024 x 768. YOU MUST USE THIS RESOLUTION!!! }
{------------------------------------------------------------------------------}
{ Drag the crosshair over the canvas in Microsoft Paint. }
{ To run a sample script that demonstrates this programs ability, press the }
{ play button. (BETA DOESN'T HAVE THIS FUNCTIONALITY) }
{------------------------------------------------------------------------------}
{ Note that the tools leave a margin on the paint canvas (both x and y axes). }
{ This margin is equivalent to the constant CO, which can be altered to achieve}
{ optimum results. This has been accounted for in all procedures and methods }
{ interacting with the canvas, when you make new ones you should do the same. }
{ }
{ ONLY TOOLS DIRECTLY INTERACTING WITH THE CANVAS NEED THE COFACTOR CALCULATED }
{ IN (ONLY TOOLS IN THE INPUT DEVICE OR TOP-LEVEL INTERFACE) }
{ }
{=============================[Version History]================================}
{ }
{ For release notes and a complete documentation, go to the project website at }
{ [url]http://whitenoise.awardspace.com/mspaintartist/[/url] }
{ }
{ THIS IS A BETA VERSION ONLY. PLEASE POST ANY BUGS YOU MAY HAVE DETECTED! }
{ }
{==============================================================================}
{ }
{ MADE BY BOTMASTER - DO NOT DELETE THIS LINE }
{ ADD LIST OF CONTRIBUTERS/EDITORS/MODIFIERS HERE: }
{------------------------------------------------------------------------------}

const
co = 5; //Canvas Offset/Cofactor in pixels (5+ reccomended)
ot = 100; //Offset time in ms (50+ reccomended)

//Juuuust in case something goes wrong. Notifies user.
procedure Error(ErrorMsg : string);
begin
Writeln('');
Writeln('Error: '+ErrorMsg);
Playsound('C:\WINDOWS\Media\Windows XP Critical Stop.wav');
Wait(1000);
TerminateScript;
end;

//Sets up bitmaps... Nothing yet though.
procedure LoadImages;
begin

end;

{******************************************************************************}
{ Input Device Procedures }
{******************************************************************************}

//Press a key
procedure PressKey(char : byte);
begin
KeyDown(char);
Wait(ot);
KeyUp(char);
end;

//Type something
procedure TextType(text : string);
begin
SendKeys(text);
Wait(ot);
end;

//Click somewhere
procedure Click(x, y : integer);
begin
ClickMouse(x, y, true);
Wait(ot);
end;


//Drags mouse from x1,y1 to x2, y2
procedure DragFromTo(x1, y1, x2, y2 : integer);
begin
HoldMouse(x1+co, y1+co, true);
MoveMouseSmooth(x2+co,y2+co);
ReleaseMouse(x2+co, y2+co, true);
end;

{******************************************************************************}
{ Menubar Procedures }
{******************************************************************************}

//Opens top-level menus of mspaint.exe
procedure OpenTopLevelMenu(menu : string);
begin
Case lowercase(menu) of
'file' : Click(-45, -12);
'edit' : Click(-20, -12);
'view' : Click(18, -12);
'image' : Click(55, -12);
'colors' : Click(95, -12);
'help' : Click(125, -12);
end;
end;

//Not yet implemented... In future will open submenus of filemenu
procedure OpenFileMenu(menu : string);
begin
Case lowercase(menu) of
1 : menu:=menu;
end;
end;

//Set mspaint canvas size
procedure SetAttributes(width, height : integer);
begin
OpenTopLevelMenu('image');
Click(70, 70);
TextType(inttostr(width+co));
PressKey(9);
TextType(inttostr(height+co));
PressKey(13);
end;

//Self explanatory
procedure ClearImage;
begin
OpenTopLevelMenu('image');
Click(70, 85);
end;

{******************************************************************************}
{ Top-Level Interface Instructions }
{******************************************************************************}

//Select a color from rgb mix. FrontColor specifies wether the color is selected
//as the main color or background color.
procedure SelectColor(r, g, b : byte; backcolor : boolean);
begin
//If backcolor = true then

//Color Dialog box open
Click(115, -15);
Click(115, 15);
Click(390, 440);
//Gets color from RGB...
Click(685, 398);
Click(685, 398);
TextType(inttostr(r));
PressKey(9);
TextType(inttostr(g));
PressKey(9);
TextType(inttostr(b));
PressKey(13);
end;

procedure SelectTool(tool : string);
begin
Case lowercase(tool) of
'starselect': Click(-45, 10);
'select': Click(-20, 10);
'ereaser': Click(-45, 40);
'fill': Click(-20, 40);
'pick': Click(-45, 60);
'magnify': Click(-20, 60);
'draw': Click(-45, 90);
'paint': Click(-20, 90);
'spray': Click(-45, 115);
'text': Click(-20, 115);
'line': Click(-45, 140);
'curve': Click(-20, 140);
'rectangle': Click(-45, 165);
'polygon': Click(-20, 165);
'ellipse': Click(-45, 190);
'rounded': Click(-20, 190);
end;
Wait(ot);
end;

//Tools this applies to are text, starselect, and select.
procedure UseBackgroundColor(yes : boolean);
begin
If Yes = true then
Click(-35, 225)
else
Click(-35, 255);
end;

procedure ThicknessSelect(thickness : byte);
begin
Case thickness of
1: Click(-30, 216);
2: Click(-30, 228);
3: Click(-30, 240);
4: Click(-30, 252);
5: Click(-30, 265);
end;
Wait(ot);
end;

//Sets draw mode for polygon/ellipse/recangle/rounded tools
procedure SetDrawMode(mode : byte);
begin
Case Mode of
1: Click(-30, 220);
2: Click(-30, 240);
3: Click(-30, 260);
end;
Wait(ot);
end;

{******************************************************************************}
{ Tool procedures }
{******************************************************************************}

//Irregular shape select tool. Background specifies wether or not background
//stays transparent. Note that arrays must start at 1 and that the coordinate
//with the highest array count is both start and ending. This COUNTS DOWN!!!
procedure StarSelect(PointArray : TPointArray; background : boolean);
var
l : integer;
begin
SelectTool('starselect');
UseBackGroundColor(background);
l:= getarraylength(PointArray)-1;
HoldMouse((PointArray[l].x)+co, (PointArray[l].y)+co, true);
Wait(ot);
repeat
MoveMouseSmooth((PointArray[l].x)+co, (PointArray[l].y)+co);
Wait(ot);
l:= l - 1;
until(l = 1)
l:= getarraylength(PointArray)-1;
ReleaseMouse((PointArray[l].x)+co, (PointArray[l].y)+co, true);
SelectTool('polygon');
end;

procedure Select(x1, y1, x2, y2 : integer; background : boolean);
begin
SelectTool('select');
UseBackgroundColor(background);
DragFromTo(x1+co, y1+co, x2+co, y2+co);
end;

procedure Erease(x, y : integer; thickness : byte);
begin
SelectTool('ereaser');
Case thickness of
1: Click(-30, 215);
2: Click(-30, 235);
3: Click(-30, 245);
4: Click(-30, 265);
end;
Click(x+co, y+co);
end;

procedure Fill(x, y : integer);
begin
SelectTool('fill');
Click(x+co, y+co);
end;

procedure UseDropper(x, y : integer);
begin
SelectTool('pick');
Click(x+co, y+co);
end;

//Zooms in on x, y at magnification 2, 6, 8. Negative magnification restores
//1x magnification when at a higher mag.
procedure Zoom(x, y : integer; magnification : byte);
begin
SelectTool('magnify');
If not(magnification < 0) then
begin
Click(x+co, y+co);
Case magnification of
2: Click(-24, 236);
6: Click(-24, 252);
8: Click(-24, 269);
end;
end else
Click(-24, 221);
end;

//Uses pencil tool
procedure PixelPut(x, y : integer);
begin
SelectTool('draw');
Click(x+co, y+co);
Wait(ot);
end;

//Tools are numbered from left to right, top to bottom.
procedure Paint(x1, y1, x2, y2 : integer; tool : byte);
begin
SelectTool('paint');
Case tool of
1: Click(-45, 219);
2: Click(-31, 219);
3: Click(-18, 219);
4: Click(-45, 235);
5: Click(-31, 235);
6: Click(-18, 235);
7: Click(-45, 250);
8: Click(-31, 250);
9: Click(-18, 250);
10: Click(-45, 267);
11: Click(-31, 267);
12: Click(-18, 267);
end;
DragFromTo(x1+co, y1+co, x2+co, y2+co);
end;


//Times = how many times it will spray paint the same line
procedure SprayPaint(x1, y1, x2, y2, times : integer; thickness : byte);
var
density : integer;
begin
SelectTool('spray');
Case thickness of
1: Click(-41, 229);
2: Click(-21, 228);
3: Click(-33, 258);
end;
density:= times;
repeat
density:= density - 1;
DragFromTo(x1+co, y1+co, x2+co, y2+co);
until(density = 0);
end;

procedure TextTool(text : string; x1, y1, x2, y2 : integer; nobgcolor : boolean);
begin
SelectTool('text');
DragFromTo(x1+co, y1+co, x2+co, y2+co);
TextType(text);
Click(x1+co+1, y1+co+1);
end;

//Draws line from x1, y1 to x2, y2. Thickness can be 1 to 5 from thinest to
//thickest. If nothing is specified, it will use the thickness already there.
procedure Line(x1, y1, x2, y2 : integer; thickness : byte);
begin
SelectTool('line');
ThicknessSelect(thickness);
DragFromTo(x1+co, y1+co, x2+co, y2+co);
end;

//See line for arguments. cp1 and cp2 are the points which define the
//curvature points of the line. They can be the same if neccessary.
procedure Curve(x1, y1, x2, y2, cpx1, cpy1, cpx2, cpy2 : integer; thickness : byte);
begin
SelectTool('curve');
ThicknessSelect(thickness);
DragFromTo(x1+co, y1+co, x2+co, y2+co);
Click(cpx1+co, cpy1+co);
Click(cpx2+co, cpy2+co);
end;

//Rectangle tool. Drawmode specifies wether the rectangle be drawn filled in,
//with or without border. In top-bottom order (1, 2, and 3 are applicable
//parameters).
procedure Rectangle(x1, y1, x2, y2 : integer; drawmode : byte);
begin
SelectTool('rectangle');
SetDrawMode(drawmode);
DragFromTo(x1+co, y1+co, x2+co, y2+co);
end;

//Draws poly. See StarSelect tool for array help, rectangle tool for drawmode
//help.
procedure Polygon(PointArray : TPointArray; drawmode : byte);
var
l : integer;
begin
SelectTool('polygon');
SetDrawMode(drawmode);
l:= getarraylength(PointArray)-1;
DragFromTo((PointArray[l].x)+co, (PointArray[l].y)+co, (PointArray[l-1].x)+co, (PointArray[l-1].y)+co);
l:= l - 1;
repeat
Click((PointArray[l].x)+co, (PointArray[l].y)+co);
l:= l - 1;
until(l = 1)
l:= getarraylength(PointArray)-1;
Click((PointArray[l].x)+co, (PointArray[l].y)+co);
SelectTool('starselect');
end;

//See rectangle tool for arguments. Draws Ellipse.
procedure Ellipse(x1, y1, x2, y2 : integer; drawmode : byte);
begin
SelectTool('ellipse');
SetDrawMode(drawmode);
DragFromTo(x1+co, y1+co, x2+co, y2+co);
end;

//See rectangle tool for arguments. Draws rounded square.
procedure Rounded(x1, y1, x2, y2 : integer; drawmode : byte);
begin
SelectTool('rounded');
SetDrawMode(drawmode);
DragFromTo(x1+co, y1+co, x2+co, y2+co);
end;

begin

end.

Download it to use, the SCAR tags thingmabobs are messing everything up :( ! They're just for preview.

Yakman

2006-11-28 17:57:19

wow thats quite good, you spend a lot of work on it

iv got a suggestion, if you get a plugin for SCAR which lets you run executable files, use that for opening paint just by running the SCAR script

i think i saw one of these plugins on moparisthebest, in SCAR development i think
also freddys plugin opens SCSS and SCARBrowser

Flyboy

2006-11-28 23:29:41

Very nice. I usually start on MSPaint when I get an idea and have to re-figureout all the stuff you just did… Please update here as you progress… I will definitly be using it :-) !!!

botmaster

2006-11-29 05:46:34

Right, I'm still working on this piece of ****. Still working on the menubars… The biggest challenge is figuring out all those coordinates :eek:. Just hate doing that, its boring and timeconsuming :(. Eeeh, maybe I'll let someone else do it for me :mrgreen:.

Freddy1990

2006-11-29 07:30:49

From: Yakman
wow thats quite good, you spend a lot of work on it

iv got a suggestion, if you get a plugin for SCAR which lets you run executable files, use that for opening paint just by running the SCAR script

i think i saw one of these plugins on moparisthebest, in SCAR development i think
also freddys plugin opens SCSS and SCARBrowser


Bah, i think a plugin that allows you to open any file from scar is too dangerous, people kan eailly keylog you like that and stuff

Nice job btw

Yakman

2006-11-29 17:45:17

From: Freddy1990
Bah, i think a plugin that allows you to open any file from scar is too dangerous, people kan eailly keylog you like that and stuff

Nice job btw


no need to open Any program, just open MsPaint

your plugin only opens SCSS and SCARBrowser, im quite sure it can be made to only open Paint

botmaster

2006-11-29 17:56:25

Too dangerous though, people can easily use SCAR to program assembler and alter interrupts in the CPU, haven't tried it but its possible with most PASCAL compilers/scripting engines (ever heard of asm/i386 compatible?) . In combination with windows-shell access (like calling programs), this can pose a serious security risk.

I'm NOT going to make it use a plugin, as they are far too dangerous with SCAR at the present moment. Sure, I might add an optional add-on that you can download, but I first want to finish the complete interface layer to paint before I start doing plugins or anything.

Hint: to quickly run microsoft paint, press windows key+r, then type "mspaint" and hit enter.

EDIT: YAY! Figured out a way to avoid coordinates. After all, what are key-combos for ;).