Results 1 to 7 of 7

Thread: Clicks where you click?

  1. #1
    Join Date
    Mar 2009
    Location
    About six feet off the ground.
    Posts
    95
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Lightbulb Clicks where you click?

    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

  2. #2
    Join Date
    May 2008
    Posts
    1,345
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    If IsMouseButtonDown(true/false) Then
    Begin
      getmousepos(x, y);
      Tpoint[var].x := X
      Tpoint[var].y := Y;
    End;

    ~Sandstorm

  3. #3
    Join Date
    Mar 2009
    Location
    About six feet off the ground.
    Posts
    95
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    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

  4. #4
    Join Date
    Oct 2007
    Location
    Denmark
    Posts
    409
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    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.

  5. #5
    Join Date
    Nov 2007
    Location
    Chile
    Posts
    1,901
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    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.


  6. #6
    Join Date
    Mar 2009
    Location
    About six feet off the ground.
    Posts
    95
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    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

  7. #7
    Join Date
    Oct 2007
    Location
    Denmark
    Posts
    409
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by zeeky111 View Post
    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.
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •