Results 1 to 7 of 7

Thread: how to make simba random what it types

  1. #1
    Join Date
    May 2018
    Posts
    3
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default how to make simba random what it types

    is there any way to make simba randomise what numbers or letters it types?

  2. #2
    Join Date
    Dec 2011
    Posts
    2,147
    Mentioned
    221 Post(s)
    Quoted
    1068 Post(s)

    Default

    Quote Originally Posted by tarmokeijo View Post
    is there any way to make simba randomise what numbers or letters it types?
    Could you elaborate on what you are specifically trying to do? Else, this is a pretty literal example of what you're asking.

    Simba Code:
    program randomTyper;

    const
      MSG_LENGTH = 10;
      POSSIBLE_CHARS = '1234567890abcdefghijklmnopqrstuvwxyz';

    var
      i: integer;
      randomChar: char;

    begin
      for i := 0 to (MSG_LENGTH - 1) do
      begin
        randomChar := POSSIBLE_CHARS[random(0, length(POSSIBLE_CHARS) - 1)];
        writeln(randomChar);
        sendKeys(randomChar, 60 + random(60), 60 + random(60));
      end;
    end.

  3. #3
    Join Date
    May 2018
    Posts
    3
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    just like that what i was wanting to do, thanks

  4. #4
    Join Date
    May 2018
    Posts
    3
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Clarity View Post
    Could you elaborate on what you are specifically trying to do? Else, this is a pretty literal example of what you're asking.

    Simba Code:
    program randomTyper;

    const
      MSG_LENGTH = 10;
      POSSIBLE_CHARS = '1234567890abcdefghijklmnopqrstuvwxyz';

    var
      i: integer;
      randomChar: char;

    begin
      for i := 0 to (MSG_LENGTH - 1) do
      begin
        randomChar := POSSIBLE_CHARS[random(0, length(POSSIBLE_CHARS) - 1)];
        writeln(randomChar);
        sendKeys(randomChar, 60 + random(60), 60 + random(60));
      end;
    end.
    how i could get this to work inside a procedure that does more thing than just that

  5. #5
    Join Date
    Dec 2006
    Location
    Program TEXAS home of AUTOERS
    Posts
    7,934
    Mentioned
    26 Post(s)
    Quoted
    237 Post(s)

    Default

    Quote Originally Posted by tarmokeijo View Post
    how i could get this to work inside a procedure that does more thing than just that
    Simba Code:
    program randomTyper;

    const
      MSG_LENGTH = 10;
      POSSIBLE_CHARS = '1234567890abcdefghijklmnopqrstuvwxyz';

    var
      i: integer;
      randomChar: char;

    Procedure random;
    begin
      for i := 0 to (MSG_LENGTH - 1) do
      begin
        randomChar := POSSIBLE_CHARS[random(0, length(POSSIBLE_CHARS) - 1)];
        writeln(randomChar);
        sendKeys(randomChar, 60 + random(60), 60 + random(60));
        // after it types the random sentence, do something here...
      end;
    end;

    begin
    repeat
     random;
    until(false);
    end.

  6. #6
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    Quote Originally Posted by P1nky View Post
    Simba Code:
    program randomTyper;

    const
      MSG_LENGTH = 10;
      POSSIBLE_CHARS = '1234567890abcdefghijklmnopqrstuvwxyz';

    var
      i: integer;
      randomChar: char;

    Procedure random;
    begin
      for i := 0 to (MSG_LENGTH - 1) do
      begin
        randomChar := POSSIBLE_CHARS[random(0, length(POSSIBLE_CHARS) - 1)];
        writeln(randomChar);
        sendKeys(randomChar, 60 + random(60), 60 + random(60));
        // after it types the random sentence, do something here...
      end;
    end;

    begin
    repeat
     random;
    until(false);
    end.
    Random() is already defined, so you should probably use a better name...
    Also bad practice to keep 'i' as a global variable.

    @Clarity, your example will not behave as expected, since POSSIBLE_CHARS is treated as a string, i.e. indexed from 1, not 0.

    @OP, here is an alternative answer:
    Simba Code:
    program RandomTyper;

    procedure TypeRandomMessage(const MessageLength: UInt32);
    const
      CHARS: String = '0123456789abcdefghijklmnopqrstuvwxyz';
    var
      i: UInt32;
      S: String;
    begin
      SetLength(S, MessageLength);
      for i := 1 to MessageLength do
        S[i] := CHARS[Random(1, Length(CHARS))];
      SendKeys(S, Random(70, 100), Random(60, 90));
    end;

    begin
      ClearDebug();
      TypeRandomMessage(14);
    end.

  7. #7
    Join Date
    Dec 2011
    Posts
    2,147
    Mentioned
    221 Post(s)
    Quoted
    1068 Post(s)

    Default

    Quote Originally Posted by Citrus View Post
    @Clarity, your example will not behave as expected, since POSSIBLE_CHARS is treated as a string, i.e. indexed from 1, not 0.
    I learn something new every week from Mr. Citrus.

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
  •