pwnaz0r
09-23-2007, 04:57 AM
Here are some functions i threw together. You probably didn't know they existed. Feel free to try them out and use in scripts (please credit though!).
-----------------------------------------------------------------------------
ChangeTMName - Changes the name on task manager. Makes the script less detectable.
ScarToFront - brings the SCAR client to the front
WindowTransparent - makes any window be partially transparent
SCARTransparent - Makes SCAR Partially transparent
OpenDialog - Opens a dialog (this would be like a file browser)
OpenDialogRaw - Same as OpenDialog except you can change the filter words(don't use unless you know what your doing);
OpenColorDialog - Opens a color dialog(use it to find out what it is)
HiglightColorsBitmap - Select a bitmap with FileManager. Will highlight any color you choose to the color 65535(yellow)
CallError - Calls a custom error
RaiseError - Calls a specific error. View function to find different kinds.
Explode - Thanks Sumilion, internal function
GetFileText - Gets the text in a file.
-----------------------------------------------------------------------------
{ -- Changes the Task Manager Name -- Makes it less detectable -- }
function ChangeTMName(name: string): boolean;
var
s: string;
begin
try
s:= GetSelf.Caption;
GetApplication.Title:= Name;
GetSelf.Caption:= s;
result:= true;
except
result:= false;
Writeln('Could not change the Task Manager name');
end;
end;
{ -- Brings SCAR to Front -- }
function ScarToFront: boolean;
begin
try
GetApplication.BringToFront;
result:= true;
except
result:= false;
Writeln('Could not bring SCAR to front');
end;
end;
function WindowTransparent(Percent: integer;WindowName: string; CaseSensitive: boolean): boolean;
var
Percent2: extended;
handle, PHandle: integer;
begin
try
PHandle:= GetClientWindowHandle;
FindWindowTitlePart(WindowName, CaseSensitive);
Handle:= GetClientWindowHandle;
Percent2:= Percent * 2.5;
Percent:= Ceil(Percent2);
if (Percent >= 255) then
begin
Writeln('Please do not make windows 100% transparent, you will loose');
Writeln('all contact with it');
result:= false;
exit;
end;
MakeWindowTransparent(Handle, (255 - Percent));
except
result:= false;
Writeln('Could not make SCAR transparent');
end;
SetClientWindowHandle(PHandle);
end;
{ -- Makes the SCAR Screen Transparent -- }
function SCARTransparent(Percent: integer): boolean;
var
Percent2: extended;
begin
try
Percent2:= Percent * 2.5;
Percent:= Ceil(Percent2);
if Percent >= 255 then
begin
Writeln('Please do not make SCAR 100% transparent, you will loose');
Writeln('all files within it');
result:= false;
exit;
end;
MakeWindowTransparent(GetSelf.Handle, (255 - Percent));
except
result:= false;
Writeln('Could not make SCAR transparent');
end;
end;
{ -- Opens File Dialog -- Saves Filename as result -- }
function OpenDialog(ScriptsOnly: boolean): string;
var
TheDialog: TOpenDialog;
begin
result:= 'nil';
try
TheDialog := TOpenDialog.Create(nil);
if ScriptsOnly then
TheDialog.Filter:= 'SCAR Files|*.scar|Text Files|*.txt*'
else
TheDialog.Filter:= 'All Files|*.*';
if TheDialog.Execute then
result:= ExtractFilePath(TheDialog.FileName)+ExtractFileNam e(TheDialog.FileName)
except
Writeln('Could not open dialog');
end;
TheDialog.Free;
end;
{ -- Opens File Dialog -- Same As OpenDialog except filter is custom -- }
function OpenDialogRaw(Filters: string): string;
var
TheDialog: TOpenDialog;
begin
result:= 'nil';
try
TheDialog := TOpenDialog.Create(nil);
TheDialog.Filter:= Filters;
if TheDialog.Execute then
result:= ExtractFilePath(TheDialog.FileName)+ExtractFileNam e(TheDialog.FileName)
except
Writeln('Could not open dialog');
end;
TheDialog.Free;
end;
{ -- Thanks Sumilion, purely internal -- }
function Explode(cDelimiter, sValue : string; iCount : integer) : TStringArray;
var
s: string;
i,p : integer;
begin
s := sValue; i := 0;
while length(s) > 0 do
begin
Inc(i);
SetLength(result, i);
p := pos(cDelimiter,s);
if ( p > 0 ) and ( ( i < iCount ) OR ( iCount = 0) ) then
begin
Result[i - 1] := copy(s,0,p-1);
s := copy(s,p + length(cDelimiter),length(s));
end else
begin
result[i - 1] := s;
s := '';
end;
end;
end;
{ -- Gets the file text -- }
function GetFileText: TStringArray;
var
s, text: string;
h: integer;
begin
s:= OpenDialog(true);
if (s = 'nil') then
begin
writeln('Error picking file');
exit;
end;
h:= OpenFile(s, false);
if (h <> -1) then
begin
ReadFileString(h, text, FileSize(h));
result:= Explode('', text, 0);
end else
Writeln('Error opening file');
end;
{ -- Opens A Color Dialog and Saves the color to the variable "Color" -- }
function OpenColorDialog(var Color: integer): boolean;
var
TheDialog: TColorDialog;
begin
try
TheDialog := TColorDialog.Create(nil);
if TheDialog.Execute then
Color:= TheDialog.Color;
except
result:= false;
Writeln('Could not open dialog');
end;
TheDialog.Free;
end;
{ -- Opens File Dialog -- Will Highlight All of "Color" -- }
function HiglightColorsBitmap(Color: TColor): boolean;
var
TheFileName: string;
TheColor1, TheColor2: TColor;
TheBitmap, l, w: integer;
c: TCanvas;
a, b: byte;
UseColorPicker: boolean;
begin
UseColorPicker:= false;// Set To True to use color form
try
TheFileName:= OpenDialogRaw('BMP|*.bmp|PNG|*.png|JPEG|*.jpeg*');
if UseColorPicker then
begin
OpenColorDialog(Color)
end;
TheColor1:= Color;
TheColor2:= 65535;
TheBitmap:= LoadBitmap(TheFileName);
GetBitmapSize(TheBitmap, w, l);
c:= GetBitMapCanvas(TheBitmap);
for a:= 0 to w do
for b:= 0 to l do
if FastGetPixel(TheBitmap, a, b) = TheColor1 then
begin
Writeln('Color Changed at ('+IntToStr(a)+','+IntToStr(b)+') from '+IntToStr(TheColor1)+' to '+IntToStr(TheColor2));
FastSetPixel(TheBitMap, a, b, TheColor2);
end;
SaveBitmap(TheBitmap,TheFileName);
result:= true;
except
Writeln('Could not open file');
end;
end;
function CallError(Reason: string): boolean;
begin
RaiseException(erCustomError,Reason);
end;
function RaiseError(typeoferror, reason: string): boolean;
{.types include
cannotimport = Error in importing
couldnotcallproc = Error in calling a procedure
dividebyzero = Cannot Divide by zero
exception = An exception, basic
interfacenotsupported = Does not support interface
internalerror = Error that is internal
outofrange = Number is out of range
outofmemory = No memory left
typemismatch = Mismatch in type
}
begin
case LowerCase(typeoferror) of
'cannotimport': RaiseException(erCannotImport, reason);
'couldnotcallproc': RaiseException(erCouldNotCallProc, reason);
'dividebyzero': RaiseException(ErDivideByZero, reason);
'exception': RaiseException(erException, reason);
'interfacenotsupported': RaiseException(erInterfaceNotSupported, reason);
'internalerror': RaiseException(ErInternalError, reason);
'outofrange': RaiseException(ErOutOfRange, reason);
'outofmemory': RaiseException(erOutOfMemory, reason);
'typemismatch': RaiseException(erTypemismatch, reason);
end;
end;
-----------------------------------------------------------------------------
ChangeTMName - Changes the name on task manager. Makes the script less detectable.
ScarToFront - brings the SCAR client to the front
WindowTransparent - makes any window be partially transparent
SCARTransparent - Makes SCAR Partially transparent
OpenDialog - Opens a dialog (this would be like a file browser)
OpenDialogRaw - Same as OpenDialog except you can change the filter words(don't use unless you know what your doing);
OpenColorDialog - Opens a color dialog(use it to find out what it is)
HiglightColorsBitmap - Select a bitmap with FileManager. Will highlight any color you choose to the color 65535(yellow)
CallError - Calls a custom error
RaiseError - Calls a specific error. View function to find different kinds.
Explode - Thanks Sumilion, internal function
GetFileText - Gets the text in a file.
-----------------------------------------------------------------------------
{ -- Changes the Task Manager Name -- Makes it less detectable -- }
function ChangeTMName(name: string): boolean;
var
s: string;
begin
try
s:= GetSelf.Caption;
GetApplication.Title:= Name;
GetSelf.Caption:= s;
result:= true;
except
result:= false;
Writeln('Could not change the Task Manager name');
end;
end;
{ -- Brings SCAR to Front -- }
function ScarToFront: boolean;
begin
try
GetApplication.BringToFront;
result:= true;
except
result:= false;
Writeln('Could not bring SCAR to front');
end;
end;
function WindowTransparent(Percent: integer;WindowName: string; CaseSensitive: boolean): boolean;
var
Percent2: extended;
handle, PHandle: integer;
begin
try
PHandle:= GetClientWindowHandle;
FindWindowTitlePart(WindowName, CaseSensitive);
Handle:= GetClientWindowHandle;
Percent2:= Percent * 2.5;
Percent:= Ceil(Percent2);
if (Percent >= 255) then
begin
Writeln('Please do not make windows 100% transparent, you will loose');
Writeln('all contact with it');
result:= false;
exit;
end;
MakeWindowTransparent(Handle, (255 - Percent));
except
result:= false;
Writeln('Could not make SCAR transparent');
end;
SetClientWindowHandle(PHandle);
end;
{ -- Makes the SCAR Screen Transparent -- }
function SCARTransparent(Percent: integer): boolean;
var
Percent2: extended;
begin
try
Percent2:= Percent * 2.5;
Percent:= Ceil(Percent2);
if Percent >= 255 then
begin
Writeln('Please do not make SCAR 100% transparent, you will loose');
Writeln('all files within it');
result:= false;
exit;
end;
MakeWindowTransparent(GetSelf.Handle, (255 - Percent));
except
result:= false;
Writeln('Could not make SCAR transparent');
end;
end;
{ -- Opens File Dialog -- Saves Filename as result -- }
function OpenDialog(ScriptsOnly: boolean): string;
var
TheDialog: TOpenDialog;
begin
result:= 'nil';
try
TheDialog := TOpenDialog.Create(nil);
if ScriptsOnly then
TheDialog.Filter:= 'SCAR Files|*.scar|Text Files|*.txt*'
else
TheDialog.Filter:= 'All Files|*.*';
if TheDialog.Execute then
result:= ExtractFilePath(TheDialog.FileName)+ExtractFileNam e(TheDialog.FileName)
except
Writeln('Could not open dialog');
end;
TheDialog.Free;
end;
{ -- Opens File Dialog -- Same As OpenDialog except filter is custom -- }
function OpenDialogRaw(Filters: string): string;
var
TheDialog: TOpenDialog;
begin
result:= 'nil';
try
TheDialog := TOpenDialog.Create(nil);
TheDialog.Filter:= Filters;
if TheDialog.Execute then
result:= ExtractFilePath(TheDialog.FileName)+ExtractFileNam e(TheDialog.FileName)
except
Writeln('Could not open dialog');
end;
TheDialog.Free;
end;
{ -- Thanks Sumilion, purely internal -- }
function Explode(cDelimiter, sValue : string; iCount : integer) : TStringArray;
var
s: string;
i,p : integer;
begin
s := sValue; i := 0;
while length(s) > 0 do
begin
Inc(i);
SetLength(result, i);
p := pos(cDelimiter,s);
if ( p > 0 ) and ( ( i < iCount ) OR ( iCount = 0) ) then
begin
Result[i - 1] := copy(s,0,p-1);
s := copy(s,p + length(cDelimiter),length(s));
end else
begin
result[i - 1] := s;
s := '';
end;
end;
end;
{ -- Gets the file text -- }
function GetFileText: TStringArray;
var
s, text: string;
h: integer;
begin
s:= OpenDialog(true);
if (s = 'nil') then
begin
writeln('Error picking file');
exit;
end;
h:= OpenFile(s, false);
if (h <> -1) then
begin
ReadFileString(h, text, FileSize(h));
result:= Explode('', text, 0);
end else
Writeln('Error opening file');
end;
{ -- Opens A Color Dialog and Saves the color to the variable "Color" -- }
function OpenColorDialog(var Color: integer): boolean;
var
TheDialog: TColorDialog;
begin
try
TheDialog := TColorDialog.Create(nil);
if TheDialog.Execute then
Color:= TheDialog.Color;
except
result:= false;
Writeln('Could not open dialog');
end;
TheDialog.Free;
end;
{ -- Opens File Dialog -- Will Highlight All of "Color" -- }
function HiglightColorsBitmap(Color: TColor): boolean;
var
TheFileName: string;
TheColor1, TheColor2: TColor;
TheBitmap, l, w: integer;
c: TCanvas;
a, b: byte;
UseColorPicker: boolean;
begin
UseColorPicker:= false;// Set To True to use color form
try
TheFileName:= OpenDialogRaw('BMP|*.bmp|PNG|*.png|JPEG|*.jpeg*');
if UseColorPicker then
begin
OpenColorDialog(Color)
end;
TheColor1:= Color;
TheColor2:= 65535;
TheBitmap:= LoadBitmap(TheFileName);
GetBitmapSize(TheBitmap, w, l);
c:= GetBitMapCanvas(TheBitmap);
for a:= 0 to w do
for b:= 0 to l do
if FastGetPixel(TheBitmap, a, b) = TheColor1 then
begin
Writeln('Color Changed at ('+IntToStr(a)+','+IntToStr(b)+') from '+IntToStr(TheColor1)+' to '+IntToStr(TheColor2));
FastSetPixel(TheBitMap, a, b, TheColor2);
end;
SaveBitmap(TheBitmap,TheFileName);
result:= true;
except
Writeln('Could not open file');
end;
end;
function CallError(Reason: string): boolean;
begin
RaiseException(erCustomError,Reason);
end;
function RaiseError(typeoferror, reason: string): boolean;
{.types include
cannotimport = Error in importing
couldnotcallproc = Error in calling a procedure
dividebyzero = Cannot Divide by zero
exception = An exception, basic
interfacenotsupported = Does not support interface
internalerror = Error that is internal
outofrange = Number is out of range
outofmemory = No memory left
typemismatch = Mismatch in type
}
begin
case LowerCase(typeoferror) of
'cannotimport': RaiseException(erCannotImport, reason);
'couldnotcallproc': RaiseException(erCouldNotCallProc, reason);
'dividebyzero': RaiseException(ErDivideByZero, reason);
'exception': RaiseException(erException, reason);
'interfacenotsupported': RaiseException(erInterfaceNotSupported, reason);
'internalerror': RaiseException(ErInternalError, reason);
'outofrange': RaiseException(ErOutOfRange, reason);
'outofmemory': RaiseException(erOutOfMemory, reason);
'typemismatch': RaiseException(erTypemismatch, reason);
end;
end;