Results 1 to 2 of 2

Thread: Something went wrong with simba

  1. #1
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default Something went wrong with simba

    I forgot how to make Forms not crash... anyway this is highlighted whenever I try to hit "start" on my form

    Simba Code:
    procedure ShowFormModal;
    begin
      DsgnForm.ShowModal;
    end;

    End; is highlighted



    if you need script:

    Simba Code:
    {$I SRL/SRL.Simba}
    {$I P07Include.Simba}
    var
      DsgnForm:TForm;
      BuyLabel,TLabel1,YLabel,TLabel5,TextLabel: TLabel;
      XEdit, YEdit, OptionEdit, UptextEdit:TEdit;
      StartButton:Tbutton;
      Uptext,OptionText,XStr,YStr:String;
      C_1, C_2, C_3, C_4, C_5, C_6, C_7, C_8, C_9, C_10,
      C_11, C_12, X, Y, I, Seed, MaxSleep:Integer;
    const
      default = 'Times New Roman';
    Procedure SuperWindMouse(xs, ys, xe, ye, gravity, wind, minWait, maxWait, maxStep, targetArea: extended);
    Var
      veloX,veloY,windX,windY,veloMag,dist,randomDist,lastDist,step: extended;
      lastX,lastY,MSP,W: integer;
      sqrt2,sqrt3,sqrt5: extended;
    Begin
      MSP  := MouseSpeed;
      sqrt2:= sqrt(2);
      sqrt3:= sqrt(3);
      sqrt5:= sqrt(5);
      While hypot(xs - xe, ys - ye) > 1 Do
      Begin
        dist:= hypot(xs - xe, ys - ye);
        wind:= minE(wind, dist);
        If dist >= targetArea Then
        Begin
          windX:= windX / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
          windY:= windY / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
        End Else
        Begin
          windX:= windX / sqrt2;
          windY:= windY / sqrt2;
          If (maxStep < 3) Then
          Begin
            maxStep:= random(3) + 3.0;
          End Else
          Begin
            maxStep:= maxStep / sqrt5;
          End;
        End;
        veloX:= veloX + windX;
        veloY:= veloY + windY;
        veloX:= veloX + gravity * (xe - xs) / dist;
        veloY:= veloY + gravity * (ye - ys) / dist;
        if hypot(veloX, veloY) > maxStep then
        Begin
          randomDist:= maxStep / 2.0 + random(round(maxStep) div 2);
          veloMag:= sqrt(veloX * veloX + veloY * veloY);
          veloX:= (veloX / veloMag) * randomDist;
          veloY:= (veloY / veloMag) * randomDist;
        End;
        lastX:= Round(xs);
        lastY:= Round(ys);
        xs:= xs + veloX;
        ys:= ys + veloY;

        Case Random(50) Of
          1..25: W := (MSP + (Random((MSP/4))));
          26..50: W := (MSP - (RandomRange((MSP/2), MSP-1)));
        End;
        If (W < 1) Then
          W := 1;

        If (lastX <> Round(xs)) Or (lastY <> Round(ys)) Then
          MoveMouse(Round(xs), Round(ys));

        step:= hypot(xs - lastX, ys - lastY);
        wait(W);
        lastdist:= dist;
      end;

      If (Round(xe) <> Round(xs)) or (Round(ye) <> Round(ys)) Then
        MoveMouse(Round(xe), Round(ye));

      MouseSpeed := MSP;
    End;

    Procedure HumanMMouse(eX, eY, ranX, ranY: Integer);
    Var
      randSpeed: extended;
      X,Y,X2,Y2,j,Dist,MP: integer;
    Begin
      j := MouseSpeed;
      GetMousePos(X, Y);
      Dist := Distance(X, Y, eX, eY);
      MP := Round(Dist/150);
      If MP < 0 Then
        MP := 1;

      randSpeed := (random(MouseSpeed) / 2.0 + MouseSpeed) / 10.0;
      X2 := RandomRange(eX-(j*MP), eX+(j*MP));
      Y2 := RandomRange(eY-(j*MP), eY+(j*MP));
    SuperWindMouse(X, Y, X2, Y2, 11, 8, 10.0 / randSpeed, 12.0 / randSpeed, 10.0 * randSpeed, 10.0 * randSpeed);
      GetMousePos(X, Y);
      MMouse(eX, eY, ranX, ranY);
      MouseSpeed := j;
    End;
    Function P07_ChooseOptionMultiHuman(Text: TStringArray): Boolean;
    Var
      WhiteBoxT,BlueBoxT,YellowBoxT,OrangeBoxT,FoundText: String;
      OptionTB:TBox;
      OptionBoxTPA1: TPointArray;
      NumberOfOptions,C,X,Y: Integer;
    Begin
      FindColors(OptionBoxTPA1, 4674653, P07_MSX1, P07_MSY1, P07_ClientWidth-1, P07_ClientHeight-1);
      OptionTB:=getTPABounds(OptionBoxTPA1);
      If (Length(OptionBoxTPA1) < 10) Then
      Begin
        Result:=False;
        Exit;
      End;
      NumberOfOptions:=((OptionTB.Y2-2) - (OptionTB.Y1+21)) / 14;
      For C:=0 To (NumberOfOptions-1) Do
      Begin
        If (OptionTB.Y1+21+(C*15)) > OptionTB.Y1+21+((C+1)*14) Then
        Begin
          Result:=False;
          Break;
        End;
        WhiteBoxT:=GetTextAtExWrap(OptionTB.X1+2, OptionTB.Y1+21+(C*15), OptionTB.X2-2, OptionTB.Y1+21+((C+1)*14), 0, 5, 1, 16777215, 5, 'P07UpChars');
        BlueBoxT:=GetTextAtExWrap(OptionTB.X1+2, OptionTB.Y1+21+(C*15), OptionTB.X2-2, OptionTB.Y1+21+((C+1)*14), 0, 5, 1, 16776960, 5, 'P07UpChars');
        YellowBoxT:=GetTextAtExWrap(OptionTB.X1+2, OptionTB.Y1+21+(C*15), OptionTB.X2-2, OptionTB.Y1+21+((C+1)*14), 0, 5, 1, 65535, 5, 'P07UpChars');
        OrangeBoxT:=GetTextAtExWrap(OptionTB.X1+2, OptionTB.Y1+21+(C*15), OptionTB.X2-2, OptionTB.Y1+21+((C+1)*14), 0, 5, 1, 4231423, 5, 'P07UpChars');
        FoundText:=WhiteBoxT+' '+BlueBoxT+YellowBoxT+OrangeBoxT;
        If (P07_ContainsText(FoundText,Text)) Then
        Begin
          HumanMMouse(RandomRange(OptionTB.X1+2,OptionTB.X2-2),RandomRange(OptionTB.Y1+21+(C*14),OptionTB.Y1+21+((C+1)*14)),0,0);
          ClickMouse2(mouse_left);
          Result:=True;
          Exit;
        End;
      End;
      GetMousePos(X,Y);
      If Y > 21 Then
        HumanMMouse(RandomRange(OptionTB.X1+2,OptionTB.X2-2),RandomRange(Y-10,Y-20),0,0)
      Else
        HumanMMouse(RandomRange(5,535),RandomRange(350,490),0,0);
      Result:=False;
    End;
    Procedure RandomChooseWait;
    Begin
      case random(1000) of
        1..860:    Wait(RandomRange(C_7, C_8));
        861..975:  Wait(RandomRange(C_9, C_10));
        976..1000: Wait(RandomRange(C_11, C_12));
      End;
    End;
    Procedure FastWait;
    Begin
      case random(1000) of
        1..860:    Wait(RandomRange(C_1, C_2));
        861..975:  Wait(RandomRange(C_3, C_4));
        976..1000: Wait(RandomRange(C_5, C_6));
      End;
    End;
    Procedure HumanMovePoint;
    Begin
      case random(200) of
        1..160:   HumanMMouse(RandomRange(X - 5, X + 5), RandomRange(y - 5, y + 5), 0, 0);
        161..190: HumanMMouse(RandomRange(X - 8, X + 8), RandomRange(y - 7, y + 7), 0, 0);
        191..200: HumanMMouse(RandomRange(X - 10, X + 10), RandomRange(y - 10, y + 10), 0, 0);
      End;
    End;
    Procedure MainLoop;
    Begin
      Try
        For I:=0 To 3 Do
        If (P07_IsUpTextMultiCustom(['' + UpText])) then
        Begin
          Case Random(100) Of
            1..94:
            Begin
              HumanMovePoint;
              FastWait;
              clickmouse2(mouse_Right);
              P07_ChooseOptionMultiHuman(['',+ OptionText]);
              Exit;
            End;
            95..100:
            Begin
              FastWait;
              clickmouse2(mouse_Right);
              P07_ChooseOptionMultiHuman(['',+ OptionText]);
            End;
          End;
        End;
      Except
        Writeln('Could Not Find Uptext')
        Wait(RandomRange(0,MaxSleep))
        HumanMovePoint;
        MainLoop;
        Exit;
      Finally
        FastWait;
      End;
    End;
    Procedure SetSpot;
    Begin
      HumanMMouse(X,Y,0,0)
    End;
    Procedure SeedWaits;
    Begin
      C_1 := RandomRange(0,23)
      C_2 := RandomRange(83,206)
      C_3 := RandomRange(154,350)
      C_4 := RandomRange(452,757)
      C_5 := RandomRange(127,403)
      C_6 := RandomRange(609,1043)
      C_7 := RandomRange(63,259)
      C_8 := RandomRange(404,654)
      C_9 := RandomRange(254,476)
      C_10 := RandomRange(557,712)
      C_11 := RandomRange(356,556)
      C_12 := RandomRange(803,1276)
      MaxSleep := RandomRange(432,4848)
    End;

    procedure SaveFormInfo(Sender: TObject);
    begin
      DsgnForm.ModalResult := mrOk;
      UpText := UptextEdit.TEXT
      OptionText := OptionEdit.TEXT
      XStr :=  XEdit.TEXT
      YStr :=  YEdit.TEXT
      X := StrToInt(XStr)
      Y := StrToInt(YStr)
      DsgnForm.CLOSE;
    end;

    procedure InitForm;
    begin
     DsgnForm:=TForm.Create(nil);
      with DsgnForm do
        begin
          Caption:='2007 Auto Buyer 1.0';
          Left:=274;
          Top:=333;
          Width:=230;
          Height:=240;
          Font.Name:=default;
          Font.Color:=clDefault;
          Font.Size:=0;
      end;
     BuyLabel:=TLabel.Create(DsgnForm);
      with BuyLabel do
        begin
          Parent:=DsgnForm;
          Caption:='RJJ95 Auto Buyer';
          Left:=60;
          Top:=10;
          Width:=87;
          Height:=14;
          Font.Name:=default;
          Font.Color:=clDefault;
          Font.Size:=12;
      end;
     TLabel1:=TLabel.Create(DsgnForm);
      with TLabel1 do
        begin
          Parent:=DsgnForm;
          Caption:='X';
          Left:=50;
          Top:=45;
          Width:=7;
          Height:=14;
          Font.Name:=default;
          Font.Color:=clDefault;
          Font.Size:=11;
      end;
     YLabel:=TLabel.Create(DsgnForm);
      with YLabel do
        begin
          Parent:=DsgnForm;
          Caption:='Y';
          Left:=110;
          Top:=45;
          Width:=7;
          Height:=14;
          Font.Name:=default;
          Font.Color:=clDefault;
          Font.Size:=11;
      end;
     TLabel5:=TLabel.Create(DsgnForm);
      with TLabel5 do
        begin
          Parent:=DsgnForm;
          Caption:='Option Name';
          Left:=75;
          Top:=75;
          Width:=63;
          Height:=14;
          Font.Name:=default;
          Font.Color:=clDefault;
          Font.Size:=11;
      end;
      TextLabel:=TLabel.Create(DsgnForm);
      with TextLabel do
        begin
          Parent:=DsgnForm;
          Caption:='Uptext';
          Left:=90;
          Top:=125;
          Width:=63;
          Height:=14;
          Font.Name:=default;
          Font.Color:=clDefault;
          Font.Size:=11;
      end;
     XEdit:=TEdit.Create(DsgnForm);
      with XEdit do
        begin
          Parent:=DsgnForm;
          Text:='1';
          Left:=70;
          Top:=43;
          Width:=40;
          Height:=21;
          Font.Name:=default;
          Font.Color:=clDefault;
          Font.Size:=10;
      end;
     XEdit:=TEdit.Create(DsgnForm);
      with XEdit do
        begin
          Parent:=DsgnForm;
          Text:='1';
          Left:=123;
          Top:=43;
          Width:=40;
          Height:=21;
          Font.Name:=default;
          Font.Color:=clDefault;
          Font.Size:=10;
      end;
     OptionEdit:=TEdit.Create(DsgnForm);
      with OptionEdit do
        begin
          Parent:=DsgnForm;
          Text:='';
          Left:=55;
          Top:=100;
          Width:=117;
          Height:=21;
          Font.Name:=default;
          Font.Color:=clDefault;
          Font.Size:=10;
        End;
      StartButton:=TButton.Create(DsgnForm);
      with StartButton do
        begin
          Parent:=DsgnForm;
          Caption:='Start';
          Left:=30;
          Top:=195;
          Width:=170;
          Height:=20;
          OnClick:=@SaveFormInfo
          Font.Size:=9;
      end;
      UptextEdit:=TEdit.Create(DsgnForm);
      with UptextEdit do
        begin
          Parent:=DsgnForm;
          Text:='';
          Left:=55;
          Top:=145;
          Width:=117;
          Height:=21;
          Font.Name:=default;
          Font.Color:=clDefault;
          Font.Size:=10;
      end;
    end;

    procedure SafeInitForm;
    var
      v: TVariantArray;
    begin
      setarraylength(V, 0);
      ThreadSafeCall('InitForm', v);
    end;


    procedure ShowFormModal;
    begin
      DsgnForm.ShowModal;
    end;


    procedure SafeShowFormModal;
    var
      v: TVariantArray;
    begin
      SetArrayLength(V, 0);
      ThreadSafeCall('ShowFormModal', v);
    end;


    begin
      SetupP07Include;
      MouseSpeed :=15;
      SafeInitForm;
      SafeShowFormModal;
      ActivateClient;
      SeedWaits;
      SetSpot;
      MainLoop;
      Repeat
      MainLoop;
      Until IsKeyDown(113);
    end.


    Can't find the difference between the saving method of this one and my Fletcher so I can't figure out the problem

  2. #2
    Join Date
    Dec 2010
    Posts
    89
    Mentioned
    4 Post(s)
    Quoted
    8 Post(s)

    Default

    Are you looking for something like this?

    Simba Code:
    ThreadSafeCall('IntializeForm', Params);
    frmMainBody.Free;

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
  •