SRL Archive - Other Scripts

Mouse Macro


Daniel

2009-08-22 17:23:23

Mouse Macro, by Dan's The Man…

This script is simple. It records your mouse movement and outputs it in a nice, SCAR-friendly scar script in the debug box :D

Also, you might just want to delete the first 4 lines of the output'ed script (yes, it detects the run button clicks :p)

Anyways, have fun ;)

{$DEFINE Debug} //Add a // in front of this line (so it turns green) to not clear
// the debug box (the box which is located at the bottom left of SCAR)
//Mouse Macro by Mayazcherquoi (a.k.a Dan's The Man)
//Records and outputs a SCAR-compatible script of your mouse movements and
//actions.
//Press F12 or CTRL+ALT+S to stop the script.

program MouseMacro;

var
cx, cy, lx, ly, wt, mD, wtB, sT, Count: Integer;
IMBDL, IMBDR: Boolean;

procedure ScriptTerminate;
begin
Alert('Recording has stopped');
Writeln('end.');
GetSelf.WindowState := wsNormal;
end;

begin
GetSelf.WindowState := wsMinimized;
{$ifDef Debug}
ClearDebug;
{$endIf}
sT := 3;
Writeln('program New;');
Writeln(' //Written by Mouse Macro, which was written by Mayazcherquoi (a.k.a Dan''s The Man)');
Writeln('');
Writeln('procedure ScriptTerminate;');
Writeln('begin');
Writeln(' GetSelf.WindowState := wsNormal;');
Writeln('end;');
Writeln('');
Writeln('begin');
Writeln(' GetSelf.WindowState := wsMinimized;');
repeat
Alert('Starting in: ' + IntToStr(sT));
Dec(sT);
Wait(995);
Until(sT = 0);
Alert('Recording has Started');
wt := GetTimeRunning;
repeat
GetMousePos(cx, cy);
wtB := GetTimeRunning - wt;
if((cx <> lx) or (cy <> ly)) then
begin
if(not(wtB <= 0)) then
begin
Writeln(' Wait(' + IntToStr(wtB) + ');');
wt := GetTimeRunning;
end;
Writeln(' MoveMouse(' + IntToStr(cx) + ', ' + IntToStr(cy) + ');');
lx := cx;
ly := cy;
end;
IMBDL := IsMouseButtonDown(True);
IMBDR := IsMouseButtonDown(False);
if((IMBDL) and (not(mD = 1))) then
begin
if(not(GetTimeRunning - wt <= 0)) then
begin
Writeln(' Wait(' + IntToStr(wtB) + ');');
wt := GetTimeRunning;
end;
Writeln(' HoldMouse(' + IntToStr(cx) + ', ' + IntToStr(cy) + ', True);');
mD := 1;
end else
if(not(IMBDL) and (mD = 1)) then
begin
if(not(wtB <= 0)) then
begin
Writeln(' Wait(' + IntToStr(wtB) + ');');
wt := GetTimeRunning;
end;
Writeln(' ReleaseMouse(' + IntToStr(cx) + ', ' + IntToStr(cy) + ', True);');
mD := 0;
end;
if((IMBDR) and (not(mD = 2))) then
begin
if(not(wtB <= 0)) then
begin
Writeln(' Wait(' + IntToStr(wtB) + ');');
wt := GetTimeRunning;
end;
Writeln(' HoldMouse(' + IntToStr(cx) + ', ' + IntToStr(cy) + ', False);');
mD := 2;
end else
if(not(IMBDR) and (mD = 2)) then
begin
if(not(wtB <= 0)) then
begin
Writeln(' Wait(' + IntToStr(wtB) + ');');
wt := GetTimeRunning;
end;
Writeln(' ReleaseMouse(' + IntToStr(cx) + ', ' + IntToStr(cy) + ', False);');
mD := 0;
end;
if(IsFKeyDown(12)) then
TerminateScript;
Until(False);
end.

Laimonas171

2009-08-22 17:55:59

great! :) i will test it right now.

First Post YAY.!

EDIT: works great just lags a little bit. but i think after script start tou should do CLS debug (to remove text). (clear it) because now you just cannot CTRL-A :) (scar advert-news text at the up of debug..)


//Mouse Macro by Mayazcherquoi (a.k.a Dan's The Man)
//Records and outputs a SCAR-compatible script of your mouse movements and
//actions.

program MouseMacro;

var
cx, cy, lx, ly, wt, mD, wtB: Integer;

procedure ScriptTerminate;
begin
Writeln('end.');
end;

begin
ClearDebug;// Laimonas171 EDIT.
Writeln('program New;');
Writeln(' //Written by Mouse Macro, which was written by Mayazcherquoi (a.k.a Dan''s The Man)');
Writeln('begin');
repeat
GetMousePos(cx, cy);
wtB := GetTimeRunning - wt;
if((cx <> lx) or (cy <> ly)) then
begin
if(not(wtB <= 0)) then
begin
Writeln(' Wait(' + IntToStr(wtB) + ');');
wt := GetTimeRunning;
end;
Writeln(' MoveMouse(' + IntToStr(cx) + ', ' + IntToStr(cy) + ');');
lx := cx;
ly := cy;
end;
if(IsMouseButtonDown(True)) then
begin
if(mD = 1) then
Continue;
if(not(GetTimeRunning - wt <= 0)) then
begin
Writeln(' Wait(' + IntToStr(wtB) + ');');
wt := GetTimeRunning;
end;
Writeln(' HoldMouse(' + IntToStr(cx) + ', ' + IntToStr(cy) + ', True);');
mD := 1;
end else
if(IsMouseButtonDown(False)) then
begin
if(mD = 2) then
Continue;
if(not(wtB <= 0)) then
begin
Writeln(' Wait(' + IntToStr(wtB) + ');');
wt := GetTimeRunning;
end;
Writeln(' HoldMouse(' + IntToStr(cx) + ', ' + IntToStr(cy) + ', False);');
mD := 2;
end;
case (mD) of
1: if(not(IsMouseButtonDown(True))) then
begin
if(not(wtB <= 0)) then
begin
Writeln(' Wait(' + IntToStr(wtB) + ');');
wt := GetTimeRunning;
end;
Writeln(' ReleaseMouse(' + IntToStr(cx) + ', ' + IntToStr(cy) + ', True);');
mD := 0;
end;
2: if(not(IsMouseButtonDown(False))) then
begin
if(not(wtB <= 0)) then
begin
Writeln(' Wait(' + IntToStr(wtB) + ');');
wt := GetTimeRunning;
end;
Writeln(' ReleaseMouse(' + IntToStr(cx) + ', ' + IntToStr(cy) + ', False);');
mD := 0;
end;
end;
Until(False);
end.

Daniel

2009-08-23 04:00:08

Erm, i know of ClearDebug and know what it does :p

It's just that some people might want to keep their contents ;) Just like the SCAR DFM Form Loader, does it clear the debug lines? No.

And as for lag, i experience absolutely none. But if you do, you can add a wait(1) at the end of the loop ;)

Daniel

2009-08-25 11:56:16

Updated :D

Thanks Laimonas for a suggestion which MAY be useful to people :)

Laimonas171

2009-08-25 14:16:20

[QUOTE=Dan's The Man;620679]Updated :D

Thanks Laimonas for a suggestion which MAY be useful to people :)[/QUOTE]

Np. :)

l 3 3 t6

2009-09-15 23:43:45

Cool simple script, might use for some easier tasks in runescape or anything.

Daniel

2009-09-16 15:29:31

Updated:

- Increased speed significantly
- There should be ZERO lag now
- Improved code efficiency

:) I see people use this :p

rya

2009-10-26 18:43:28

Is there anyway to shorten this cuz i made a antiban thing with this and the anti was over 10,000 line :fiery:

MaksasMks

2009-11-08 13:11:09

Thnx man!

Bionicle

2009-11-08 13:35:26

From: rya
Is there anyway to shorten this cuz i made a antiban thing with this and the anti was over 10,000 line :fiery:


how the hell……

edit: yea tried it out, this is pretty cool. good job, rep+ :p

MaksasMks

2009-11-08 13:52:47

How to make that script reapet again and again?

Griff

2009-11-08 14:00:06

From: MaksasMks
How to make that script reapet again and again?


repeat

until(false)

That would make an endless loop, but I hope you understand.

Bionicle

2009-11-08 14:05:07

From: Griff721
repeat

until(false)

That would make an endless loop, but I hope you understand.


if you want it to go only a certin amount of times, do

program new;

Var
R: Integer;

begin
repeat
Inc(R); //adds one to the integer, it would start as 0 and keep going up each loop by one
[code]
Until(R=10); //or what ever number of times you want
end.

MaksasMks

2009-11-08 14:14:22

I forgot everything about Scar. I used the scar before 2007. If u can plz help, I need that very much.
For example, didn't work:
program New;
//Written by Mouse Macro, which was written by Mayazcherquoi (a.k.a Dan's The Man)

Var
R: Integer;

procedure ScriptTerminate;
begin
GetSelf.WindowState := wsNormal;
end;


begin
GetSelf.WindowState := wsMinimized;
MoveMouse(769, 502);
HoldMouse(769, 502, True);
HoldMouse(769, 502, False);
ReleaseMouse(769, 502, False);
Wait(50);
HoldMouse(769, 502, True);
Wait(100);
ReleaseMouse(769, 502, True);
Wait(1022);
MoveMouse(772, 502);
Wait(10);

repeat
Inc(R); //adds one to the integer, it would start as 0 and keep going up each loop by one
Until(R=10); //or what ever number of times you want
end.

Bubix

2009-11-08 14:14:58

So what i understood from this is that this scirpt records mouse movment..

and Then i can play a scirp and it does a wroted mouse movments again?

Like record and then play?
did i get it write?

MaksasMks

2009-11-08 14:19:29

Yes.

ZaSz

2009-11-08 14:25:35

program New;
//Written by Mouse Macro, which was written by Mayazcherquoi (a.k.a Dan's The Man)

Var
R: Integer;

procedure ScriptTerminate;
begin
GetSelf.WindowState := wsNormal;
end;


begin
repeat
GetSelf.WindowState := wsMinimized;
MoveMouse(769, 502);
HoldMouse(769, 502, True);
HoldMouse(769, 502, False);
ReleaseMouse(769, 502, False);
Wait(50);
HoldMouse(769, 502, True);
Wait(100);
ReleaseMouse(769, 502, True);
Wait(1022);
MoveMouse(772, 502);
Wait(10);
Inc(R); //adds one to the integer, it would start as 0 and keep going up each loop by one
Until(R=10); //or what ever number of times you want
end.

we want it to repeat everything inside the repeat until…

MaksasMks

2009-11-08 14:29:49

It works, big thnx for all :) If that script could write… :)

Bubix

2009-11-08 14:45:35

huh yea it works, but in one game i wanted to write mouse, it writes, but when i press to play this mouse movment, it isn`t going accually the same way.. ;/
its like a large lag or somth..

ZaSz

2009-11-08 14:47:53

if your using mouse instead of clickmouse, you need to include srl and call setupsrl; right at the beginning of your mainloop.