Results 1 to 4 of 4

Thread: TypeMistakes ~ Text.scar

  1. #1
    Join Date
    May 2007
    Location
    England
    Posts
    4,141
    Mentioned
    11 Post(s)
    Quoted
    266 Post(s)

    Default TypeMistakes ~ Text.scar

    Here are a few functions which are sort of like AddMistakes and TypeSend in one, but with a twist.

    What they do are, type the message, and randomly make mistakes, just like AddMistakes, but instead, these backspace, and correct the mistake. You have the choice of choosing the % of making a mistake, and whether you want to press enter or not. I'll leave the rest to the code:

    SCAR Code:
    {*******************************************************************************
    procedure TypeMistakesExPC(Text : string; PressEnter : Boolean; PC_Chance : Integer);
    By: R1ch
    Description: Types Text with mistakes, then fixes them. Presses enter depending
                 on PressEnter. PC_Chance = % of making a mistake.
    *******************************************************************************}

    procedure TypeMistakesExPC(Text : string; PressEnter : Boolean; PC_Chance : Integer);
    var
      I, Q : Integer;
      L : TStringArray;

    begin
      L:= ['q','r','t','y','u','i','o','p','a','s','d','f','g','h','j','k','l','z','x','c','v','b','n','m','1','2','3','4','5','6','7','8','9','0','[',']',';','#',',','.','/','\'];
      I:= Length(Text);
      for I:= 1 to (High(Text) - 1) do
      begin
        case Random(100) of
          PC_Chance..100 : TypeSendEx(Text[i], False);
          0..(PC_Chance-1) : begin
                               Q:= Random(High(L));
                               if (L[Q] <> Text[i]) then
                               begin
                                 TypeSendEx(L[Q], False);
                                 Wait(250 + Random(1000));
                                 TypeByte(VK_BACK);
                                 Wait(RandomRange(250, 850));
                               end;
                               TypeSendEx(Text[i], False);
                             end;
        end;
      end;
      TypeSendEx(Text[i], PressEnter);
    end;

    {*******************************************************************************
    procedure TypeMistakesEx(Text : string; PressEnter : Boolean);
    By: R1ch
    Description: Types Text with mistakes and fixes them.
                 Presses enter depending on PressEnter
    *******************************************************************************}

    procedure TypeMistakesEx(Text : string; PressEnter : Boolean);
    begin
      TypeMistakesExPC(Text, PressEnter, RandomRange(4, 16));
    end;

    {*******************************************************************************
    procedure TypeMistakesPC(Text : string; Chance : Integer);
    By: R1ch
    Description: Types Text with mistakes and fixes them. Presses enter.
                 Chance = % of making a mistake.
    *******************************************************************************}

    procedure TypeMistakesPC(Text : string; Chance : Integer);
    begin
      TypeMistakesExPC(Text, True, Chance);
    end;

    {*******************************************************************************
    procedure TypeMistakes(Text : string);
    By: R1ch
    Description: Types Text with mistakes and fixes them. Presses enter.
    *******************************************************************************}

    procedure TypeMistakes(Text : string);
    begin
      TypeMistakesEx(Text, True);
    end;

    Ok. Well I made a few more than I may have needed to, but oh well...

    Comments?
    Last edited by Rich; 07-09-2009 at 02:40 PM.
    <3

    Quote Originally Posted by Eminem
    I don't care if you're black, white, straight, bisexual, gay, lesbian, short, tall, fat, skinny, rich or poor. If you're nice to me, I'll be nice to you. Simple as that.

  2. #2
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    SCAR Code:
    (PC_Chance + 1)..100 : TypeSendEx(Text[i], False);

    should be

    SCAR Code:
    0..(PC_Chance-1) : TypeSendEx(Text[i], False);

  3. #3
    Join Date
    Feb 2008
    Posts
    517
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Not sure if you got this idea from me or not, as I was talking about it quite a lot on IRC, but here is what I have.

    SCAR Code:
    program Zzz;
    var keyboard, shiftboard, current: array [0..3] of string;
        mistypeprobability:integer;
        lastletter:string;
       
        { Things that are not finished:
       
                 ~Improve mistake probabilities
                 ~Mistake fixing with backspace
                 ~Adding capitalization of letters
                 
                                                              }


    procedure KeyboardVars;
    begin
         keyboard[0] := '`1234567890-= ';   shiftboard[0] := '~!@#$%^&*()_+' ;
         keyboard[1] := ' qwertyuiop[]\';   shiftboard[1] := ' QWERTYUIOP{}|';
         keyboard[2] := ' asdfghjkl;''' ;   shiftboard[2] := ' ASDFGHJKL:"'  ;
         keyboard[3] := ' zxcvbnm,./'   ;   shiftboard[3] := ' ZXCVBNM<>?'   ;
    end;

    procedure Letter(character:char);
    var key:byte;
    begin
         key := GetKeyCode(character);
         KeyDown(key);
         Wait(25+Random(35));
         KeyUp(key);
    end;

    procedure PressEnter();
    begin
         Letter(Chr(13));
    end;

    procedure PressBack();
    begin
         Letter(Chr(8));
    end;

    function TypeLetter(character:char; mistake:boolean):boolean;
    var normal, shift:string;
        i, position, positioni:integer;
        key:char;
    begin
         result := false;
         if character = ' ' then
         begin
              Letter(' ');
              Exit;
         end;
         normal := '`1234567890-=qwertyuiop[]\asdfghjkl;''zxcvbnm,./';
         shift  := '~!@#$%^&*()_+QWERTYUIOP}{|ASDFGHJKL:"ZXCVBNM<>?' ;
         if Pos(character, normal) <> 0 then
            current := keyboard;
         if Pos(character, shift) <> 0 then
            current := shiftboard;
         for i := 0 to 3 do
         begin
              if Pos(character, current[i]) <> 0 then
                 positioni := i;
         end;
         position := Pos(character, current[positioni]);
         key := current[positioni][position];
         if mistake then
         begin
              case Random(120 + mistypeprobability) of
                0..2: // Longer wait, ex. forget key location or something
                begin
                     Wait(30+Random(100));
                     mistypeprobability := mistypeprobability + 4;
                end;
                3..15: // Shorter wait, ex. small brainfart
                begin
                     Wait(Random(40));
                     mistypeprobability := mistypeprobability + 2;
                end;
                16: // No letter typed
                begin
                     result := true;
                     Exit;
                end;
                17..20: // Chance to mistype letter on the same row
                begin
                     position := position - 1 + Random(3);
                     if position < 1 then
                        position := 1;
                     if (positioni > 0) and (position < 2) then
                        position := 2;
                     if position > Length(current[positioni]) then
                        position := Length(current[positioni]);
                     key := current[positioni][position];
                     result := true;
                     mistypeprobability := mistypeprobability + 10;
                end;
                21: // Mistype the letter upward
                begin
                     positioni := positioni + 1;
                     if positioni > 3 then
                        positioni := 3;
                     key := current[positioni][position];
                     result := true;
                     mistypeprobability := mistypeprobability + 10;
                end;
                22: // Mistype the letter downward
                begin
                     positioni := positioni - 1;
                     if positioni < 0 then
                        positioni := 0;
                     key := current[positioni][position];
                     result := true;
                     mistypeprobability := mistypeprobability + 10;
                end;
                23..250: // No mistype, increase the chance to mistype for the next letter
                begin
                     mistypeprobability := mistypeprobability - 1;
                end;
              end;
         end;
         Letter(key);
    end;

    procedure TypeText(text:string; mistake, fix:boolean);
    var i, n, t:integer;
        b:boolean;
    begin
         i := 1;
         n := 0;
         b := false;
         mistypeprobability := 5;
         while (i <= Length(text)) do
         begin
              if fix then
              begin
              if (TypeLetter(text[i], mistake)) and (b = false) then
              begin
                 b := true;
                 n := i;
              end;
              if (random(8) = 0) and (b) then
              begin
                 Wait(70+Random(280));
                 for t := 1 to (i - n+1) do
                 begin
                      Wait(40+Random(40));
                      PressBack;
                 end;
                 i := n - 1;
                 b := false;
              end;
              end else
              begin
                 TypeLetter(text[i], mistake);
              end;
              Wait(15+Random(15));
              i := i + 1;
         end;
         lastletter := 'none';
     //    Script Load Up
    end;

    begin
         KeyboardVars;
         TypeText('harry was a small litte boy, he had no brains but was a very happy child, other children were very envious of his happiness so they went to a witch doctor with horrible intentions.',true,true);
    end.

    It basically does mistakes that a normal human would, and also corrects them as a normal human would, it doesn't always recognize that you made a mistake right away, so it continues typing, and than deletes it and restarts from that location. It isn't completely finished yet, and I'm aware of a very small bug that I'm trying to fix as I'm writing this.

  4. #4
    Join Date
    May 2007
    Location
    England
    Posts
    4,141
    Mentioned
    11 Post(s)
    Quoted
    266 Post(s)

    Default

    Quote Originally Posted by marpis View Post
    SCAR Code:
    (PC_Chance + 1)..100 : TypeSendEx(Text[i], False);

    should be

    SCAR Code:
    0..(PC_Chance-1) : TypeSendEx(Text[i], False);
    Will change in a second.

    Quote Originally Posted by Feroc1ty View Post
    Not sure if you got this idea from me or not, as I was talking about it quite a lot on IRC, but here is what I have.

    SCAR Code:
    program Zzz;
    var keyboard, shiftboard, current: array [0..3] of string;
        mistypeprobability:integer;
        lastletter:string;
       
        { Things that are not finished:
       
                 ~Improve mistake probabilities
                 ~Mistake fixing with backspace
                 ~Adding capitalization of letters
                 
                                                              }


    procedure KeyboardVars;
    begin
         keyboard[0] := '`1234567890-= ';   shiftboard[0] := '~!@#$%^&*()_+' ;
         keyboard[1] := ' qwertyuiop[]\';   shiftboard[1] := ' QWERTYUIOP{}|';
         keyboard[2] := ' asdfghjkl;''' ;   shiftboard[2] := ' ASDFGHJKL:"'  ;
         keyboard[3] := ' zxcvbnm,./'   ;   shiftboard[3] := ' ZXCVBNM<>?'   ;
    end;

    procedure Letter(character:char);
    var key:byte;
    begin
         key := GetKeyCode(character);
         KeyDown(key);
         Wait(25+Random(35));
         KeyUp(key);
    end;

    procedure PressEnter();
    begin
         Letter(Chr(13));
    end;

    procedure PressBack();
    begin
         Letter(Chr(8));
    end;

    function TypeLetter(character:char; mistake:boolean):boolean;
    var normal, shift:string;
        i, position, positioni:integer;
        key:char;
    begin
         result := false;
         if character = ' ' then
         begin
              Letter(' ');
              Exit;
         end;
         normal := '`1234567890-=qwertyuiop[]\asdfghjkl;''zxcvbnm,./';
         shift  := '~!@#$%^&*()_+QWERTYUIOP}{|ASDFGHJKL:"ZXCVBNM<>?' ;
         if Pos(character, normal) <> 0 then
            current := keyboard;
         if Pos(character, shift) <> 0 then
            current := shiftboard;
         for i := 0 to 3 do
         begin
              if Pos(character, current[i]) <> 0 then
                 positioni := i;
         end;
         position := Pos(character, current[positioni]);
         key := current[positioni][position];
         if mistake then
         begin
              case Random(120 + mistypeprobability) of
                0..2: // Longer wait, ex. forget key location or something
                begin
                     Wait(30+Random(100));
                     mistypeprobability := mistypeprobability + 4;
                end;
                3..15: // Shorter wait, ex. small brainfart
                begin
                     Wait(Random(40));
                     mistypeprobability := mistypeprobability + 2;
                end;
                16: // No letter typed
                begin
                     result := true;
                     Exit;
                end;
                17..20: // Chance to mistype letter on the same row
                begin
                     position := position - 1 + Random(3);
                     if position < 1 then
                        position := 1;
                     if (positioni > 0) and (position < 2) then
                        position := 2;
                     if position > Length(current[positioni]) then
                        position := Length(current[positioni]);
                     key := current[positioni][position];
                     result := true;
                     mistypeprobability := mistypeprobability + 10;
                end;
                21: // Mistype the letter upward
                begin
                     positioni := positioni + 1;
                     if positioni > 3 then
                        positioni := 3;
                     key := current[positioni][position];
                     result := true;
                     mistypeprobability := mistypeprobability + 10;
                end;
                22: // Mistype the letter downward
                begin
                     positioni := positioni - 1;
                     if positioni < 0 then
                        positioni := 0;
                     key := current[positioni][position];
                     result := true;
                     mistypeprobability := mistypeprobability + 10;
                end;
                23..250: // No mistype, increase the chance to mistype for the next letter
                begin
                     mistypeprobability := mistypeprobability - 1;
                end;
              end;
         end;
         Letter(key);
    end;

    procedure TypeText(text:string; mistake, fix:boolean);
    var i, n, t:integer;
        b:boolean;
    begin
         i := 1;
         n := 0;
         b := false;
         mistypeprobability := 5;
         while (i <= Length(text)) do
         begin
              if fix then
              begin
              if (TypeLetter(text[i], mistake)) and (b = false) then
              begin
                 b := true;
                 n := i;
              end;
              if (random(8) = 0) and (b) then
              begin
                 Wait(70+Random(280));
                 for t := 1 to (i - n+1) do
                 begin
                      Wait(40+Random(40));
                      PressBack;
                 end;
                 i := n - 1;
                 b := false;
              end;
              end else
              begin
                 TypeLetter(text[i], mistake);
              end;
              Wait(15+Random(15));
              i := i + 1;
         end;
         lastletter := 'none';
     //    Script Load Up
    end;

    begin
         KeyboardVars;
         TypeText('harry was a small litte boy, he had no brains but was a very happy child, other children were very envious of his happiness so they went to a witch doctor with horrible intentions.',true,true);
    end.

    It basically does mistakes that a normal human would, and also corrects them as a normal human would, it doesn't always recognize that you made a mistake right away, so it continues typing, and than deletes it and restarts from that location. It isn't completely finished yet, and I'm aware of a very small bug that I'm trying to fix as I'm writing this.
    Nope, I didn't get it from you. I haven't been on the IRC lately, so I wouldn't know that you have been working on this.
    <3

    Quote Originally Posted by Eminem
    I don't care if you're black, white, straight, bisexual, gay, lesbian, short, tall, fat, skinny, rich or poor. If you're nice to me, I'll be nice to you. Simple as that.

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
  •