SRL Archive - Other Scripts

Macro Recorder


Krazy_Meerkat

2007-08-31 19:28:53

Hey I made this a long time ago but it only had mouse movements, I added support for letters and numbers.
You can control the speed the mouse is recorded at (how long it waits before it reports the mouse xy, it will always report on clicking) and you can choose between a program or a procedure.
Stop it with Ctrl.
Target a window before starting the script or the mouse movements might not be recorded.

Use this to macro any java game you wish, it will have to be modified to make runescape scripts but yeah the engine is solid. Records exactly what happens in exactly that order, for runescape change the waits to include random numbers as such:
  writeln('  wait(' + inttostr(wate * 6) + '+random(50));')
but the number you put will slow down your script, if your script lags too much then just increase recordspeed
Also change the clicks, and the mouse movement and make those random..


program MacroRecorder;
//macro recorder, if your scripts/proccy's are too big then raise RecordSpeed
//things to do: add arrows/other functional keys
const
Output = 'Procedure'; //Making a program or a procedure?
RecordSpeed = 100; //The speed your mouse is recorded at, 1000 = 1 second
var
x, y, x2, y2, x3, y3, xx, yy, marked, wate, idlecounter,
InFile, OutFile, i, delagger : Integer;
alph, symbol, keysdown : string;
rightdown, leftdown, flag : Boolean;

procedure reportwait;
begin
writeln(' wait(' + inttostr(wate * 6) + ');')
wate:= 0;
end;

function keydowncheck: boolean; //checks a string for the pressed key
var string1: string;
begin
Result:= False;
string1:= ''+strget(alph, i)+'';
if(not(pos(string1, keysdown) > 0))then
Result:= true;
end;

procedure KeyCheck; //checks if any keys are down
var
string1: string;
inty: integer;
begin
//put other keychecks here like the shift check
for i := 1 to length(alph) do
begin
if(iskeydown(strget(alph, i)) and keydowncheck)then
begin
if(delagger < 41)then
delagger:= delagger + 1; //used to fix false positives on startup
if(delagger > 40)then
begin
reportwait;
string1:= ''+strget(alph, i)+'';
writeln(' KeyDown(GetKeyCode('''+string1+'''));');
keysdown:= ''+keysdown+''+StrGet(alph, i)+'';
end;
end else
if(not(iskeydown(strget(alph, i))))then
begin
if(delagger < 41)then
delagger:= delagger + 1; //used to fix false positives on startup
if(delagger > 40)then
begin
if(not(keydowncheck) and not(keysdown = ''))then //if the key being pressed is in the string keysdown
begin
reportwait;
string1:= ''+strget(alph, i)+'';
writeln(' KeyUp(GetKeyCode('''+string1+'''));');
inty:= pos(string1, keysdown);
delete(keysdown, inty, 1); //remove the letter from keysdown
end;
end;
end;
end;
end;

procedure MMouse;
begin
writeln(' MoveMouse(' + inttostr(x) + ', ' + inttostr(y) + ');');
xx:= x;
yy:= y;
end;

begin
alph:='abcdefghijklmnopqrstuvwxyz1234567890 ';
idlecounter:= 1;
InFile:= OpenFile(AppPath + 'includes\ProcedureNumber.txt', False);
if(InFile > -1)then
begin
ReadFileInt(InFile, idlecounter);
CloseFile(InFile);
end else
begin
OutFile:= RewriteFile(AppPath + 'includes\ProcedureNumber.txt', False);
if(OutFile > -1)then
begin
writeln('File Created ' + AppPath + 'includes\ProcedureNumber.txt');
WriteFileInt(OutFile, idlecounter);
CloseFile(OutFile);
end;
end;
idlecounter:= idlecounter + 1;
OutFile:= RewriteFile(AppPath + 'includes\ProcedureNumber.txt', False);
if(OutFile > -1)then
begin
writeln('File Created ' + AppPath + 'includes\ProcedureNumber.txt');
WriteFileInt(OutFile, idlecounter);
CloseFile(OutFile);
end;
idlecounter:= idlecounter - 1;
cleardebug;
writeln(''+Output+' New' + inttostr(idlecounter) + ';');
writeln('begin')
if(IsFunctionKeyDown(1))then
begin
repeat
wait(100);
until(not(IsFunctionKeyDown(1)));
end;
getmousepos(x, y);
wait(25);
ReleaseMouse(x, y, true);
ReleaseMouse(x, y, false);
getmousepos(xx, yy);
repeat
KeyCheck;
getmousepos(x, y);
if((not(xx = x))and(not(yy = y))and(not(Flag)))then
begin
Flag:= true;
marked:= getsystemtime;
end;
if(Flag)then
begin
if((getsystemtime - marked) > RecordSpeed)then
begin
reportwait;
MMouse;
Flag:= false;
end;
end;
if(IsMouseButtonDown(true)and(wate > 0)and(not(leftdown)))then
begin
leftdown:= true;
reportwait;
writeln(' HoldMouse(' + inttostr(x) + ', ' + inttostr(y) + ', true);');
x3:= x;
y3:= y;
end;
if(IsMouseButtonDown(false)and(wate > 0)and(not(rightdown)))then
begin
rightdown:= true;
reportwait;
writeln(' HoldMouse(' + inttostr(x) + ', ' + inttostr(y) + ', false);');
x2:= x;
y2:= y;
end;
if(not(IsMouseButtonDown(false))and(wate > 0)and(rightdown))then
begin
rightdown:= false;
if(Flag)then MMouse;
reportwait;
writeln(' ReleaseMouse(' + inttostr(x) + ', ' + inttostr(y) + ', false);');
end;
if(not(IsMouseButtonDown(true))and(wate > 0)and(leftdown))then
begin
leftdown:= false;
if(Flag)then
begin
writeln(' MoveMouse(' + inttostr(x) + ', ' + inttostr(y) + ');');
xx:= x;
yy:= y;
Flag:= false;
end;
reportwait;
writeln(' ReleaseMouse(' + inttostr(x) + ', ' + inttostr(y) + ', true);');
end;
wait(1);
wate:= wate + 1;
until(IsFunctionKeyDown(1));
if((Output = 'Program')or(Output = 'program'))then
begin
symbol:= '.';
end else
symbol:= ';';
writeln('end'+symbol);
end.

botmaster

2007-09-01 14:49:44

Cool script! Only thing that confused me was that I didn't know which key ended it, but now I know: I'ts teh contol key.

This might be useful for completing boring tasks in flash games! :p

the scar noob

2007-09-01 17:14:16

shouldn't that ban us?

Killerdou

2007-09-01 17:22:09

dont use it for runescape?

Krazy_Meerkat

2007-09-02 01:23:33

The code it outputs can easily be changed…
Oh yeah I forgot to say, stop it with ctrl..
Also, target a window before starting the script or it will bug out..