Olly
01-20-2013, 05:08 AM
Mostly for the lazy as people don't like uploading screenshots (of scripts shutting down) because they have to remove everything. So this does it for you maybe it will encourage people to upload more.
How it saves:
http://i.imgur.com/J1k26PT.png
Code(isn't the "cleanest" but it does the job):
function rs_TakeScreen(s: string): Integer;
var
tpa: TPointArray;
TIA, TIA2, TIA3: TIntegerArray;
w, h: integer;
atpa: T2DPointArray;
TPA2: TPointArray;
begin
result := BitmapFromClient(MSX1, MSY1, MSX2, MSY2);
setBitmapSize(result, 673, 350);
setLength(atpa, 3);
TPAFromBoxWrap(mmBox, atpa[0]);
FilterPointsDist(atpa[0], 0, 76, MMCX, MMCY);
TPAFromBoxWrap(IntToBox(MSCX - 13, MSCY - 20, MSCX + 13, MSCY + 20), ATPA[1]);
TPAFromTextWrap(s, statchars, w, h, atpa[2]);
GetColorsWrap(atpa[0], TIA);
TIA2 := ColorsFromTPA(ATPA[1], clRed);
TIA3 := ColorsFromTPA(ATPA[2], clRed);
OffsetTPA(atpa[0], Point(-35, -6));
OffsetTPA(atpa[2], Point(2, +336))
MergeATPAWrap(ATPA, TPA);
try
fastSetPixels(result, TPA, TIA+TIA2+TIA3);
except
writeln('rs_TakeScreen: Failed to set pixels, prehaps shutdown reason is too long!');
end;
end;
procedure rs_SaveScreenshot(reason, savePath: string);
var
bmp, x: Integer;
begin
if (not(loggedIn)) then
Exit;
bmp := rs_TakeScreen(reason);
if FileExists(savePath + ' [' + ToStr(x) +']' + '.png') then
while FileExists(savePath + ' [' + ToStr(x) + ']' + '.png') do
Inc(x);
try
SaveBitmap(bmp, savePath + ' [' + ToStr(x) + ']' + '.png');
except
writeln('rs_TakeScreenshot: Failed saving screenshot');
finally
FreeBitmap(bmp);
end;
end;
procedure shutdown(s: string);
var
path, name: string;
begin
path := AppPath + 'Scripts\OllysGnomeAgility\';
name := 'Shutdown - '+ TheDate(Date_Day)+ ' ';
rs_SaveScreenshot(s, Path + Name);
end;
How it saves:
http://i.imgur.com/J1k26PT.png
Code(isn't the "cleanest" but it does the job):
function rs_TakeScreen(s: string): Integer;
var
tpa: TPointArray;
TIA, TIA2, TIA3: TIntegerArray;
w, h: integer;
atpa: T2DPointArray;
TPA2: TPointArray;
begin
result := BitmapFromClient(MSX1, MSY1, MSX2, MSY2);
setBitmapSize(result, 673, 350);
setLength(atpa, 3);
TPAFromBoxWrap(mmBox, atpa[0]);
FilterPointsDist(atpa[0], 0, 76, MMCX, MMCY);
TPAFromBoxWrap(IntToBox(MSCX - 13, MSCY - 20, MSCX + 13, MSCY + 20), ATPA[1]);
TPAFromTextWrap(s, statchars, w, h, atpa[2]);
GetColorsWrap(atpa[0], TIA);
TIA2 := ColorsFromTPA(ATPA[1], clRed);
TIA3 := ColorsFromTPA(ATPA[2], clRed);
OffsetTPA(atpa[0], Point(-35, -6));
OffsetTPA(atpa[2], Point(2, +336))
MergeATPAWrap(ATPA, TPA);
try
fastSetPixels(result, TPA, TIA+TIA2+TIA3);
except
writeln('rs_TakeScreen: Failed to set pixels, prehaps shutdown reason is too long!');
end;
end;
procedure rs_SaveScreenshot(reason, savePath: string);
var
bmp, x: Integer;
begin
if (not(loggedIn)) then
Exit;
bmp := rs_TakeScreen(reason);
if FileExists(savePath + ' [' + ToStr(x) +']' + '.png') then
while FileExists(savePath + ' [' + ToStr(x) + ']' + '.png') do
Inc(x);
try
SaveBitmap(bmp, savePath + ' [' + ToStr(x) + ']' + '.png');
except
writeln('rs_TakeScreenshot: Failed saving screenshot');
finally
FreeBitmap(bmp);
end;
end;
procedure shutdown(s: string);
var
path, name: string;
begin
path := AppPath + 'Scripts\OllysGnomeAgility\';
name := 'Shutdown - '+ TheDate(Date_Day)+ ' ';
rs_SaveScreenshot(s, Path + Name);
end;