How would I go about writing a script that will log where you click, then play it back when you run the script?
I've seen TPointArray used before in an instance not unlike this.
How would I go about writing a script that will log where you click, then play it back when you run the script?
I've seen TPointArray used before in an instance not unlike this.
~Zeek
Last major script: November 2009
Attempted to rejoin: January 2011
Rejoining: [][][][][]
Current task: writing basic alching script
SCAR Code:If IsMouseButtonDown(true/false) Then
Begin
getmousepos(x, y);
Tpoint[var].x := X
Tpoint[var].y := Y;
End;
~Sandstorm
Ok, so can you give me an example of how to put that into a script?
~Zeek
Last major script: November 2009
Attempted to rejoin: January 2011
Rejoining: [][][][][]
Current task: writing basic alching script
You could do something like this:
SCAR Code:program New;
{.include SRL/SRL.Scar}
type
MousePoint = record
P: TPoint;
B: Boolean;
end;
MousePointArray = array of MousePoint;
var
T: Array [0..200] of MousePoint;
function Recorder: Boolean;
var
i: Integer;
begin
if IsFKeyDown(2) then
begin
Writeln('Wait one second for script to record.');
Wait(1000);
Writeln('Script is ready to record.');
while not IsFKeyDown(2) do
begin
Wait(20);
if IsMouseButtonDown(True) then
begin
T[i].B := True;
GetMousePos(T[i].P.x, T[i].P.y);
Inc(i);
Wait(200);
end;
end;
Result := True;
end else
Result := False;
end;
procedure Simulate;
var
i: Integer;
begin
for i := 1 to High(T) do
begin
if (T[i].B = True) then
Mouse(T[i].P.x, T[i].P.y, 5, 5, T[i].B);
end;
end;
begin
SetupSRL;
while not Recorder do
Wait(20);
Simulate;
end.
Use a timer every 1 millisecond saving the coordinate in a tpointarray then you press a key or something and reproduce the movements
EDIT:
ah you want the clicks, just save the coord and the click(left/true)
Last edited by Cazax; 04-11-2009 at 09:03 PM.
So, is there a way that someone who didn't understand a line of Frt's script (like me) can incorporate Cazax's advice into a script? I think what I'm mainly looking at as far as uses go is walking to a mine, then mining, then bank. And yes, I know there are far safer ways in terms of failure protection.
~Zeek
Last major script: November 2009
Attempted to rejoin: January 2011
Rejoining: [][][][][]
Current task: writing basic alching script
Added some comments:
SCAR Code:program New;
{.include SRL/SRL.Scar}
type // Makes our own type that holds:
MousePoint = record
P: TPoint; // Coordinates
B: Boolean; // Left/Right click - didn't bother making it but it's there :D
end;
var
T: Array [0..200] of MousePoint; // Makes our array to hold information
function Recorder: Boolean; // Our recording function
var // Variables
i: Integer;
begin
if IsFKeyDown(2) then // Waits for F2 to be pressed
begin
Writeln('Wait one second for script to record.'); // Just some writing
Wait(1000); // Waiting
Writeln('Script is ready to record.'); // Writing again
while not IsFKeyDown(2) do // If we don't press F2 again this will be done (pressing F2 again makes it move the mouse)
begin
Wait(20); // Waiting
if IsMouseButtonDown(True) then // Checks if Mouse Button is pressed
begin
T[i].B := True; // If True it saves the info
GetMousePos(T[i].P.x, T[i].P.y); // ^
Inc(i); // Increases our counter
Wait(200); // Waiting
end;
end;
Result := True; // Makes function true - will make the loop stop in mainloop
end else
Result := False; // If not F2 pressed loop wil continue
end;
procedure Simulate;
var
i: Integer;
begin
for i := 1 to High(T) do // Loops through recorded coordinates
begin
if (T[i].B = True) then
Mouse(T[i].P.x, T[i].P.y, 5, 5, T[i].B); // Moves the mouse
end;
end;
begin
SetupSRL;
while not Recorder do
Wait(20);
Simulate;
end.
There are currently 1 users browsing this thread. (0 members and 1 guests)