[SCAR]InterSCARMessaging

Results 1 to 3 of 3
  1. #1
    The Gamma..? EliteGM is offline
    MemberRank
    Jul 2006 Join Date
    NandolandLocation
    4,078Posts

    [SCAR]InterSCARMessaging

    Nobody here might know SCAR, but heck, I'll still post it. You can download the latest SCAR version (3.21) at http://freddy1990.com/

    I've already posted this in the Public Test Corner on SRL-forums (http://villavu.com/), so I'll just quote myself :)

    Spoiler:

    Quote Originally Posted by Floor66(=EliteGM)@SRL-Forums
    The Idea
    I'm sitting here at home, being ill, so I thought, why not make up something useless in SCAR! It's been quite a while since I produced any code :p
    Anyway, this time it's InterSCARMessaging; using this you can make two (or more) SCAR's on the same computer communicate, sending messages, integers, booleans, etc. I've only used simple messages for now.

    How
    I use two scripts, a 'Sender' and a 'Receiver' (whereas the Sender constantly checks for F-key presses and then sends the corresponding command via InterSCARMessaging to other SCAR instances currently running).
    So Sender sends a command through a channel when you press an F-key, and the Receiver is constantly checking 10 different channels to see if there's a command being put through them.
    I've made it clear all channels after a command has been executed, this is necessary!

    Receiver.scar
    Code:
    Program New;
    
    {*************************************************
        ~~ SendInterSCARMessage test by Floor66 ~~
              THIS IS THE RECEIVING SCRIPT
    
        Contains:
         * Co-operates with the SENDER
         * A maximum of 10 channels (can be changed by
           changing the array length of 'Received')
         * Clears all channels after a command has
           been sent, to prevent bugs
    **************************************************}
    
    Var
      Received : TStringArray;
    
    Procedure ClearAllChannels;
    Var
      i : Integer;
    Begin
      For i := 0 To High(Received) Do
        SendInterSCARMessage(IntToStr(i), '');
    End;
    
    Procedure ScriptTerminate;
    Begin
      ClearAllChannels;
    End;
    
    Procedure Proggy;
    Begin
      WriteLn('---------------------------------');
      WriteLn('    ~SCARMessager by Floor66~    ');
      WriteLn('You sent command: progress report');
      WriteLn('---------------------------------');
    End;
    
    Procedure HandleMsg(Command : String; id : Integer);
    Begin
      Case LowerCase(Command) Of
        'progress report': Proggy;
        'stop script': TerminateScript;
        'clear debug': ClearDebug;
      End;
      Wait(150);
      ClearAllChannels;
    End;
    
    Procedure CheckChannels;
    Var
      i : Integer;
    Begin
      For i := 0 To High(Received) Do
      Begin
        Received[i] := LowerCase(ReadInterSCARMessage(IntToStr(i)));
        If Received[i] <> '' Then
          HandleMsg(Received[i], i);
      End;
    End;
    
    Procedure Init;
    Begin
      ClearAllChannels;
      SetLength(Received, 10);
    End;
    
    Begin
      Init;
      Repeat
        CheckChannels;
        Wait(10);
      Until(False);
    End.
    Sender.scar
    Code:
    Program New;
    
    {*************************************************
        ~~ SendInterSCARMessage test by Floor66 ~~
              THIS IS THE SENDING SCRIPT
    
        Contains:
         * Co-operates with the RECEIVER
         * In the procedure 'Init' you can change the
           amount of commands, what they do(*) and
           which F-key activates them!
         * The integer 'Received' here must be equal
           to the array length of 'Received' in the
           RECEIVER
           
         (*): Make sure this matches with the
              'HandleMsg' procedure in the RECEIVING
              script!
    **************************************************}
    
    Var
      Commands : TStringArray;
      CommandsFKeys : TIntegerArray;
      Received : Integer;
    
    Procedure ClearAllChannels;
    Var
      i : Integer;
    Begin
      For i := 0 To Received Do
        SendInterSCARMessage(IntToStr(i), '');
    End;
    
    Procedure ScriptTerminate;
    Begin
      ClearAllChannels;
    End;
    
    Procedure CheckFKeys;
    Var
      i : Integer;
    Begin
      For i := 0 To High(CommandsFKeys) Do
      Begin
        If IsFKeyDown(CommandsFKeys[i]) Then
          SendInterSCARMessage(IntToStr(i), Commands[i]);
      End;
    End;
    
    Procedure Init;
    Begin
      SetLength(CommandsFKeys, 12);
      SetLength(Commands, 3);
      
      Commands[0] := 'progress report';
      Commands[1] := 'stop script';
      Commands[2] := 'clear debug';
    
      CommandsFKeys[0] := 1;
      CommandsFKeys[1] := 2;
      CommandsFKeys[2] := 3;
      
      Received := 10;
    End;
    
    Begin
      Init;
      Repeat
        CheckFKeys;
        Wait(10);
      Until(False);
    End.
    Ideas for the future
    • A simple txt/ini file with the commands/fkeys/etc. so you don't have to go and change both scripts each and every time
    • Actually using it in a script
    • Maybe a simple form with a few buttons that trigger the commands, instead of F-keys (they trigger other things like a help menu (F1) or something like that aswell usually)


    SCAR's syntax looks loads like Delphi's, but SCAR also uses a bit of Pascal. It can be used for colour finding, bitmap finding, DTM (= sort of shapes) finding, mouse moving, clicking, etc.
    It's really useful to automate simple tasks, or, with certain includes (like SRL), quite advanced mouse movements (human-like) and colour/bitmap/dtm finding.


  2. #2
    Account Upgraded | Title Enabled! Intelext is offline
    MemberRank
    Mar 2007 Join Date
    EuropeLocation
    1,228Posts

    Re: [SCAR]InterSCARMessaging

    lol I thought it's Delphi at start. :D

    GJ anyways!

  3. #3
    Account Upgraded | Title Enabled! IQstim is offline
    MemberRank
    Jan 2009 Join Date
    632Posts

    Re: [SCAR]InterSCARMessaging

    mmm! nifty tool!



Advertisement