SRL Archive - OSR Help

Access Violations


Tails111

2013-05-03 18:57:14

Hello! So it has been a very long time since I have been on Simba, I actually had a tough time searching for the forums as they are now Villavu instead of srl-forums hah. Anywho!!

So I have a script that I use to log in multiple characters and use another botting thing and my script essentially just checks for various things on the Runescape screen and restarts scripts accordingly. My issue is that I have to run a second Simba script to make sure my first simba script is running. The line that always causes me errors is a basic one:

If(FindBitmapIn(TOtherScreens, TPosX, TPosY, 0, 0, 764, 549))then
begin

And I can't explain why, but for some reason, after a random amount of time, I get an access violation. The code works for an hour or two before it crashes. Sooo If anyone knows what may cause Access Violations, help would be appreciated!

NKN

2013-05-03 19:24:32

From: Tails111
Hello! So it has been a very long time since I have been on Simba, I actually had a tough time searching for the forums as they are now Villavu instead of srl-forums hah. Anywho!!

So I have a script that I use to log in multiple characters and use another botting thing and my script essentially just checks for various things on the Runescape screen and restarts scripts accordingly. My issue is that I have to run a second Simba script to make sure my first simba script is running. The line that always causes me errors is a basic one:

If(FindBitmapIn(TOtherScreens, TPosX, TPosY, 0, 0, 764, 549))then
begin

And I can't explain why, but for some reason, after a random amount of time, I get an access violation. The code works for an hour or two before it crashes. Sooo If anyone knows what may cause Access Violations, help would be appreciated!


Are you making sure TOtherScreens are valid?

you're trying to access something non-exsistant.

tealc

2013-05-03 19:25:17

The access violation could be cause by a memory leak. Are you creating multiple copies of the same bitmap?

Tails111

2013-05-04 10:02:40

I am not making sure that TOtherScreens is valid, I'll add a check in and see how it goes. And I do think it is after a memory leak, which may happen with poorly handling the bitmap. There shouldn't be creation of the bitmap more than just in the beginning, but I'll look through again.

program ScriptRunner;
{$I SRL/SRL.simba}

//Screen Dimensions, X1=0, X2=765, Y1=0, Y2=550
//Keep lines 10-83, 144 to ~146, 433-453

//Set Account13 Picture(Copy from previous)
//Set ScrollBar BMP (May Need to make new)

//Wolrd Choices: 18, 35, 36, 37, 39, 40, 44, 45, 46
// 51, 52, 53, 54, 58, 59, 62, 63, 66
// 68, 69, 70, 71, 72, 73, 74, 76, 82
// 85, 137

Var
Tx, Ty, Ti, TiZ, Tt, T6Hour, TRSBotLogo, TWorldSelect, TScriptRunning, TOtherScreens, TPlayScreen, TCloseButton, TFBButton, TLostCount, RealLostCount: Integer;
TSelectAccButton, TFaceBookLoginBug, TFaceBookLoginBug2, TScrollBar, TGameSession, TSelectAcc13, TMonsterButton, TRefreshButton, TGrotWormsButton, TStartButton, TXLogOut: Integer;

const //KEEP FROM YOURS
TCharsPlaying = 7; //Number of bots running Kenneh Fighter
TimeBetweenChecks = 1; //Time(In Seconds) between checking.

procedure TDeclarePlayers; //KEEP FROM YOURS
begin
end;

procedure TUpdateStatus(Status: String);
begin
ClearDebug;
writeln(Status);
end;

procedure TLoadDTMs;
begin
TFBButton := BitmapFromString(25, 7, 'meJxbXhqzIN17Zoz9pCAjIOr11sJ' +
'EEPHlpTF/YeDArI5OF0WIlqmh5kDtQEOWFkbMTfGYEWmFyxwgOnt0' +
'05tnD4EIbtSXT+8hIkC0JDd4cqQl0CggY3aCMx6jgLbfu3LuL24AN' +
'AGoF+geiFFAYyFGdbsrIyOgOUD04s4VPEYB3QPUCzQEYhTcHIheNL' +
'Szv/L4kgmXdq6Ca79z+iBQ5MiquUASGFZwoyBhDvELVtRiLVmtywF' +
'UDDcKaDhQpMFUECgFiRdIyMMDCqirzUEGKwJqAapENgpoDlAcqAVu' +
'FADl1w9S');
TScrollBar := BitmapFromString(5, 17, 'meJyLi4t7/fr1+/fvP3z4ACTjRhg' +
'XAKE50JY=');
TWorldSelect := BitmapFromString(14, 13, 'meJwTlFQQJAUxwAAeEYigUDAHBE' +
'GkMEXQBCHiEIAmiFXlv3//8KuEmwZRiWwypsp/qABNJVwxLjPRAgS' +
'PO3EFFFYXYgY+sn9xKcMVBSRFKxwBACcmQ70=');
TPlayScreen := BitmapFromString(21, 20, 'meJyl0M1KAmEUh/ErsEVfZC7LjM' +
'Ha9IG5iUmmaArKqWho2lRERAkRCYKEBS3cdgOuvIzuIbqEFt1Ae6m' +
'HThyGN5x5K3hwMfP/HcWo3o7q7eXj298WfcHDxrfN++P2sQeSfHVh' +
'J8dD99GxSS7ItwtX63dnk9MLYsOre+WpVi+wB9JerfU3DqTgvKl8r' +
'VPs9T6SYyMcSJtH18qX7vKpnI1woCS83Jwq3AzlqpmX99d+8ZYNS+' +
'XrB5fzW6eTlex0bdhpjUxcDD69PfeLt2xYsgdKM144tjjAw+LDKLH' +
'JbmQMyBOey4Ale7He7pnB5TfEL4jleZwDyQ1ODG5cMKxyoPST6wX+' +
'K8Na8oTivOxHym0uyIw9UBKuF1KTcZzrBcvYi11Y3f9Pc5UgtdLKd' +
'skLyXGrED711SeHhbdu');
T6Hour := BitmapFromString(19, 3, 'meJz7//+/nBAbGeg/TCMa4z8YoKm' +
'ES+HSiMs0ZFkA4p47Pg==');
TOtherScreens := BitmapFromString(9, 2, 'meJxjEzIW0/MNXn9QTMeLXVAbiMR0' +
'fYBcXjVvMaOY4BMfYq5+10vtYxW2kXDIgXDtsmYCAKhLEwY=');
TScriptRunning:= BitmapFromString(38, 2, 'meJz7/59h+jQU9B9D5OlThhXLQYx' +
'dOxnevUOXhaN9exkuX2KYMR27LNDYGTOZgOjPH3QpTJH9+xg+f2b4' +
'+5fh2VOGZcuggl++YNEINBaCfv/GaSwAuTloDg==');
TCloseButton := DTMFromString('mggAAAHicY2NgYFjIwsCwjQVCdwNxPxCvBeIFQLllQLwUiBcD8QwofvHiBcP+mlKGKzmhDGt8HBmebNnA8G7regYjoBw2zIgDQwAAaQ0Ung==');
TGameSession := BitmapFromString(29, 4, 'meJw7cuOqlZ6SubY8kASiIzeuIiM' +
'5ITa4IEQBsjK4LogIXDGQAUTIuuCCcAQRR1OGKYJmLFZBiDPgWpD9' +
'AteCyzQIA24jsmnIgsSLIDsSAMJDhHs=');
TMonsterButton := BitmapFromString(60, 5, 'meJytktEJBCEMRItJOynGSgQrsAX' +
'BBraFdHAlpIQbdkCCcffjuOCHjOP4jFaRKuKz+F21zHorGJeKuxlE' +
'KVQGnD491Ji+/NzSm2Hyaeqnot+KRJFH5PCning5NqYdk48ML/UX5' +
'qFStXT4reXYrWm5h5khKvHV+Jpc7ThUdPUq2kgen4+ey6Ao5mMaAD' +
'aSfOj6OU+EayBkeY45FCMqxK3PxCMP/ZhT5GXR3nUFfo8fmI9K3Ls' +
'xb+EbM3sYB/yEpOcL1rFHsg==');
// TFaceBookLoginBug := BitmapFromString(82, 7, 'meJzNlLERgzAMRQdjEpbwAKzAALi' +
// 'nhobWC3A0mYCDFTxB/uVfdDoLE0ORxEcBQl/oST/xdeVf1z65ftp4' +
// 'E79yHjH6ug1NFeN2STgu0b/bxnWjwg9PWNG8e3TVVSGpbwg/VvPdr' +
// 'OcZl5Zv+waPzk7YaiEh1+FSuGjGeySvA50mxpOxQDUu24icOOeokw' +
// '+JXbUr+HUdYZpUO0RgkFoJllBTYn8++u2JnHO21JYRZ4e8GThG3TD' +
// 'ioRvCih4c8kWrYTVUQp00Vk6dW5Ado2QyQfPmdo2jrUJq26TkJEb6' +
// 'Q2r7Z2VLaSOh1Dl1zthJkXLqBCHHdcnhJdSUoOFzh3OtMM8TOXn4pQ==');
// TFaceBookLoginBug2 := BitmapFromString(25, 7, 'meJybEWk9gzg0LcJqegQ+qd5g83x' +
// 'H7UInHQgqddVr9DGaEm4FVwZUUOGmn++kW+BmlO9ikO+kU+WhD9QL' +
// 'lJoUZlntARIBS+nPK4y5c+nc9bMnIOjknq3L+lsq/KwgprX7mzYnB' +
// 'R/Zuvbx7RtvXzx79fTRnSvn96xaOCPOCWhOVbDDjmVzH9y48u7l85' +
// 'dPHq7vqfmPAR7evNoVYQ80an5D0d+/f9Bkf37/Ni/dpyPaDWg4svi' +
// 'B2Z1/fv38+v4tEP3++QMuvmFyK9BeoIMh3F/fv314/hiIgMq+f/ow' +
// 'N8XzyKZVUKkf359cOfPm4Z3ZcY5zElymRdtPibBeVhLz/ctniIJjG' +
// '5fPSveHO2lzZynQkbNiHeYmuizODpyT7A530rEta4AhXOltWutpkO' +
// 'usX+JnU+xrXeJv+/zhPYiCs7s3L61IgrB/fPs6L9MfOcqARn35+AE' +
// 'iC9QCDOEz+3cAAG8uSWc=');
//TMonsterButton := BitmapFromString(24, 3, 'meJzrS1vUp6x8Y1Ha8kU3gIwt7so' + OLD MONSTER HUNTER
// '3buztgwnObtkLZJxpcb8BAwduAJWlLQfK3lgE5G7ZC+S6AxVAtB9I' +
// 'U4YzgLJo5kAQxDQ0c+AK8JsDZEPEIQgoi9UcoBUAiGRzAg==');
TRefreshButton := BitmapFromString(23, 4, 'meJxVjMENwyAMRb0SSMySnhjEyo0' +
'1EtQjO0AGYAVbnsBL1CWK1f6LH9/PqM4ytaSkCwCStqyqTTVDXlNv' +
'ocyZbbuanFuZzWWRul+yxyhyOYiIMUCEJy+AKtWmgZ3cgsvMjIMxR' +
'ubh8Fvyf07m+yscpwtEhJ0wBKLuYOVBBLDRsdET23b8Pm0dAuIbXf' +
'4ApbKnCQ==');
TGrotWormsButton := BitmapFromString(39, 3, 'meJylj9EJxAAMQjOXA7lOxnGYDOP' +
'ZBkppfw76E0RNHpFdRYu20SNWRI8bsEc2k1qJyKMWp5E5j62sVGGd' +
'aERPp4eqFY1cnpSncd3fMlO27uZJaDKmxKO/87GV9O6sfot/oScs3' +
'40nNEqhfoT+AMBp6Q4=');
TStartButton := BitmapFromString(33, 4, 'meJx1jsENAyEMBLcmpKMWXi4E8YM' +
'GUsDd+9IDFAAtWFQARcQBiaCTMg/w2t6VgS8a6CWE0oPWoEBA6R06' +
'jCFK0H3w7p1A4/8hAqC5GV60EmZaKKUN6G43wecGHFLNpkh/HK3lt' +
'gG6JUqWp5QZDr9bVsK0+5wBNQ9wCi4lp1StqQ5cqrvcMVcVy2Xw2N' +
'nlrCWTo2VmG9kqZWOUlznyYDaXfHAyGxgbz3+WlfkBEqXtsQ==');
TXLogOut := BitmapFromString(15, 2, 'meJzr3Hy4E4YYgEBIikFUCUSyi4J' +
'IBoZOJAXxXXOAyKesHUiWLtgEVQ9BDAxAEbgsEAEA3V8gkg==');
TSelectAccButton := BitmapFromString(17, 3, 'meJz78AEKzNrOnWszA5JrEhg+IAm' +
'icYFq2s59YGAwYwADIJchYc2HNQlwNVi5cEEibQFyAUihZC8=');
TSelectAcc13 := BitmapFromString(15, 3, 'meJx1jdEJADEIQ99UmcdpnMZZnCU' + //KEEP FROM YOURS
'jnNfSj+NoIKghPEFAgF1eFuFOf6XsCnYeNVP/ctsoh/Y2Zz/a5408' + //KEEP FROM YOURS
'tPn+APVgU2M='); //KEEP FROM YOURS
end;

procedure TFreeDTMS;
begin
FreeBitmap(TFBButton);
FreeBitmap(T6Hour);
FreeBitmap(TPlayScreen);
FreeBitmap(TWorldSelect);
FreeBitmap(TOtherScreens);
FreeBitmap(TScriptRunning);
FreeBitmap(TScrollBar);
FreeBitmap(TGameSession);
FreeBitmap(TMonsterButton);
FreeBitmap(TRefreshButton);
FreeBitmap(TGrotWormsButton);
FreeBitmap(TStartButton);
FreeBitmap(TXLogOut);
// FreeBitmap(TFaceBookLoginBug);
// FreeBitmap(TFaceBookLoginBug2);
FreeBitmap(TSelectAccButton);
FreeBitmap(TSelectAcc13);
FreeDTM(TCloseButton);
end;

function TClientCheck(TTx: Integer; TTy: Integer): Boolean;
begin

If(FindBitmapIn(TOtherScreens, TTx, TTy, 0, 0, 764, 549))then
begin
Result := True;
end
else
Result := False;

end;

procedure TMinimizeScreen(TClientNumber: Integer);
var
TPosX, TPosY, TX, TY: integer;
begin
TY:=875
SetDesktopAsClient;
case TClientNumber of
0:
TX:=400;
1:
TX:=400;
2:
TX:=460;
3:
TX:=520;
4:
TX:=580;
5:
TX:=640;
6:
TX:=710;
7:
TX:=770;
8:
TX:=830;
end;

Mouse(TX, TY, 1, 1, true);
wait(500);
If(FindBitMap(TScrollBar, TPosX, TPosY))then
begin
Mouse(TPosX, TPosY-46, 0, 0, true);
wait(1000);
Mouse(TX, TY, 0, 0, true);
end;
wait(1500);

end;

procedure TChooseClient(TClientNumber: Integer; SetClient: Integer);
var
TPosX, TPosY, TX, TY, TTx, TTy: integer;
begin

TRSBotLogo := BitmapFromString(29, 4, 'meJxNkDESgyAQRdfzRQsKzqMdHXe' +
'IsdOWItEyYxlso10U0gYOsJMFYsadLf78+fuWBVgNsTgALhf0Fv2b' +
'GsRApu2K6Fg5WthLC0gmZRQjPZHmnZYZ4Oeq5pXDCVht23xyG2SV7' +
'fIdG6YsDbImQQgraa8f/jTtJ4AKxyqFtTcZlHgvj1h0m5o3DgUuTY' +
'qlVotN5hGbtPbDAWu027HPV8SeI3YlciZu9Da1GMXodk3hcFqg9XI' +
'0SZAJoo+3axLBdD06w9vH7xMi9gsywtga');
TY:=875
wait(200);
SetDesktopAsClient;

case TClientNumber of
1:
TX:=400;
2:
TX:=460;
3:
TX:=520;
4:
TX:=580;
5:
TX:=640;
6:
TX:=710;
7:
TX:=770;
8:
TX:=830;
end;
if(SetClient=1)then
begin
for Tt:=0 to 5 do
begin
If(FindBitmap(TRSBotLogo, TPosX, TPosY))then
begin
TUpdateStatus(('Found Client via Logo for Bot: ' + inttostr(TClientNumber)));
MouseSetClientArea(TPosX-25, TPosY+14, TPosX+735, TPosY+568);
ImageSetClientArea(TPosX-25, TPosY+14, TPosX+735, TPosY+568);
break;
end;
If(FindBitmapIn(TOtherScreens, TPosX, TPosY, 0, 0, 764, 549))then
begin
TUpdateStatus(('Found Client via Other for Bot: ' + inttostr(TClientNumber)));
MouseSetClientArea(TPosX-289, TPosY-24, TPosX+476, TPosY+526);
ImageSetClientArea(TPosX-289, TPosY-24, TPosX+476, TPosY+526);
break;
end;
if(FindDTM(TCloseButton, TPosX, TPosY, 1, 1, 1550, 850))then
begin
TUpdateStatus(('Found Client via Close for Bot: ' + inttostr(TClientNumber)));
MouseSetClientArea(TPosX-737, TPosY+23, TPosX+35, TPosY+608);
ImageSetClientArea(TPosX-737, TPosY+23, TPosX+35, TPosY+608);
break;
end;
end;
if(SetClient=2)then
begin
TUpdateStatus('Finding RS Client.');
If(FindBitmapIn(TOtherScreens, TPosX, TPosY, 0, 0, 764, 549))then
begin
TUpdateStatus(('Found Client via Other for Bot: ' + inttostr(TClientNumber)));
MouseSetClientArea(TPosX-289, TPosY-24, TPosX+476, TPosY+526);
ImageSetClientArea(TPosX-289, TPosY-24, TPosX+476, TPosY+526);
end;
if Not(FindBitmapIn(TOtherScreens, TPosX, TPosY, 0, 0, 764, 549))then
begin
if(FindDTM(TCloseButton, TPosX, TPosY, 1, 1, 1550, 850))then
begin
TUpdateStatus(('Found Client via Close for Bot: ' + inttostr(TClientNumber)));
MouseSetClientArea(TPosX-737, TPosY+23, TPosX+35, TPosY+608);
ImageSetClientArea(TPosX-737, TPosY+23, TPosX+35, TPosY+608);
end;
end;
end;
if(SetClient=3)then
begin
SetDesktopAsClient;
wait(200);
Mouse(300,410,0,0,true);
wait(200);
Mouse(115,100,0,0,true);
wait(200);
mouse(570,460,0,0,true);
wait(2000);
end;
FreeBitmap(TRSBotLogo);
wait(1000);
end;
end;
function TGetStatus: String;
begin

If(FindBitmapToleranceIn(T6Hour, Tx, Ty, 0, 0, 764, 549, 10))then
begin
TUpdateStatus('Found 6 Hour Reset');
Result := 'Restart';
Exit;
end;

If(FindBitmapToleranceIn(TGameSession, Tx, Ty, 0, 0, 764, 549, 10))then
begin
TUpdateStatus('Found Game Session has now ended. =( ');
Result := 'Terminate';
Exit;
end;

If(FindBitmapIn(TFBButton, Tx, Ty, 0, 0, 764, 549))then
begin
TUpdateStatus('Found Login Screen');
Result := 'LoggedOut';
Exit;
end;


If(FindBitmapIn(TWorldSelect, Tx, Ty, 0, 0, 764, 549))then
begin
Result := 'WorldSelect';
TUpdateStatus('Found World Select Screen');
Exit;
end;

If(FindBitmapIn(TPlayScreen, Tx, Ty, 0, 0, 764, 549))then
begin
Result := 'PlayScreen';
TUpdateStatus('Found Play Screen');
Exit;
end;

If(FindColorTolerance(Tx, Ty, 55295, 0, 0, 190, 110, 10))then
begin
Result := 'KillingGrots';
TUpdateStatus('Found bot killing Grots by Color.');
Exit;
end;
if not(FindColorTolerance(Tx, Ty, 55295, 0, 0, 190, 110, 10))then
begin
Result := 'ScriptNotRun';
TUpdateStatus('Found the script not running by Not Finding Color.');
Exit;
end;

if(FindBitmapToleranceIn(TScriptRunning, Tx, Ty, 0, 0, 764, 549, 10))then
begin
Result := 'KillingGrots';
TUpdateStatus('Found bot killing Grots by Bitmap.');
Exit;
end;

If(FindBitmapIn(TOtherScreens, Tx, Ty, 0, 0, 764, 549))then
begin
Result := 'ScriptNotRun';
TUpdateStatus('Found the script not running.');
Exit;
end;
end;

procedure TLogPlayerIn(BotNum: Integer);
var
ti: Integer;
begin
writeln('Logging Player in.');
If(BotNum<3)then
begin
Mouse(400,275, 5, 5, true);
SendKeys(Players[BotNum-1].Name, 50, 5);
wait(200);
PressKey(13);
SendKeys(Players[BotNum-1].Pass, 50, 5);
wait(200);
PressKey(13);
wait(5000);
end;
If(BotNum>=3)then
begin
Mouse(400,275, 5, 5, true);
SendKeys(Players[BotNum].Name, 50, 5);
wait(200);
PressKey(13);
SendKeys(Players[BotNum].Pass, 50, 5);
wait(200);
PressKey(13);
wait(5000);
end;
for Ti:=0 to 12 do
begin
Ti:=Ti+1;
if(TGetStatus='PlayScreen')then
break;
if(TGetStatus='WorldSelect')then
break;
wait(5000);
end;
writeln('Ran through Logging In.');
wait(2000);
end;

procedure TLogPlayerOut(BotNum: Integer);
var
Px, Py, Pz, w, h: integer;
begin
TUpdateStatus('Logging bot ' + IntToStr(BotNum) + ' out.');
GetClientDimensions(w, h);
writeln('Started log Out.');
if(FindBitMapToleranceIn(TXLogOut, Px, Py, 0, 0,w-1,h-1,50))then
begin
writeln('Clicked X in game.');
Mouse(Px, Py, 1, 1, true);
wait(500+random(500));
Mouse(Px-115, Py+355, 10, 5, true); //Click Exit to Lobby
for Pz:=0 to 25 do
begin
wait(1000);
Mouse(Px-115, Py+355, 10, 5, true); //Click Exit to Lobby
wait(1000+random(500));
if((TGetStatus='PlayScreen')or(TGetStatus='WorldSelect')or(TGetStatus='LoggedOut'))then
Pz:=26;
end;
end;
wait(2000+random(500));
end;

procedure TPlayScripts(BotNum: Integer);
var
Px, Py, Pz, Pz2, w, h: integer;
begin
PressKey(121); //F10
wait(2000);
PressKey(120); //F9
wait(2000);
SetDeskTopAsClient;
GetClientDimensions(w, h);
For Pz2:= 0 to 15 do
begin
wait(1000);
for Pz := 0 to 10 do
begin
if(FindBitmapToleranceIn(TSelectAccButton, Px, Py,25, 100, 285, 225, 10))then
begin
writeln('Found Select acc Button');
Mouse(Px, Py, 0, 0, True); //Select Account
Break;
end;
wait(1000);
if(FindBitmapToleranceIn(TSelectAcc13, Px, Py,25, 100, 400, 400, 50))then
begin
Pz2:=16;
Pz:=11;
end;
end;
end;
writeln('Restarting Bot: ' + IntToStr(BotNum));
wait(2000);
case BotNum of //Account Selection Spacing
0: //
Mouse(190, 247, 0, 0, true); // 0 is a failsafe, have it match the coords of first spot.
1: // First Account on your list
Mouse(190, 247, 0, 0, true); //
2: //Which ever Acc is your main, do that as the bot
Mouse(190, 267, 0, 0, true); // that comes after it(add 20 to the coords.)
3: //
Mouse(190, 307, 0, 0, true); //Say MAINACCOUNT is spot 3 in power bot
4: // Put Spot four's coords in for Case 3 here
Mouse(190, 327, 0, 0, true); // then add 20 to each spot afterwards.
5: //
Mouse(190, 347, 0, 0, true);
6:
Mouse(190, 367, 0, 0, true);
7:
Mouse(190, 387, 0, 0, true);
8:
Mouse(190, 407, 0, 0, true);
9:
Mouse(190, 427, 0, 0, true);
end;
TUpdateStatus(('Starting script for Bot: ' + IntToStr(BotNum)));
wait(350);
for Pz :=0 to 50 do
begin
if(FindBitmapToleranceIn(TMonsterButton, Px, Py, 0, 0,w-1,h-1, Pz))then //Preferred Play
begin
writeln('Found Kennehs AIO Fighter Button.');
Mouse(Px+205, Py+50, 0, 0, true);
Break;
end;
if(Pz=50)then
Mouse(410, 440, 0, 0, true); //Pressing Play in Emergency
end;
SetDesktopAsClient;
GetClientDimensions(w, h);
wait(10000);
for Pz := 0 to 15 do //Waits to Find Refresh Button AKA Script Loading
begin
If(FindBitmapToleranceIn(TRefreshButton, Px, Py, 0, 0,w-1,h-1, 50))Then
begin
Mouse(Px, Py, 0, 0, true);
wait(250);
break;
end;
wait(1000);
end;
for Pz := 0 to 15 do //Waits to Find Grotworms Show Up in List
begin
If(FindBitmapToleranceIn(TGrotWormsButton, Px, Py, 0, 0,w-1,h-1, 50))Then
begin
Mouse(Px, Py, 0, 0, true);
wait(250);
break;
end
else If(FindBitmapToleranceIn(TRefreshButton, Px, Py, 0, 0,w-1,h-1, 50))Then
begin //Presses Refresh every 1 second for 15 seconds.
Mouse(Px, Py, 0, 0, true);
wait(250);
end;
wait(1000);
end;
for Pz := 0 to 5 do
begin
writeln('Searching for Start Script Button.');
If(FindBitmapToleranceIn(TStartButton, Px, Py, 0, 0,w-1,h-1, 100))Then
begin //Searches for the start Button 5 times.
Mouse(Px, Py, 0, 0, true);
wait(1000);
break;
end;
wait(1000);
end;
Presskey(27);
wait(100);
Presskey(27);
wait(100);
Presskey(27);
end;

procedure ClickPlayButton(BotNum: Integer);
var
Px, Py, Pz, w, h: Integer;

begin
TChooseClient(BotNum, 1);
wait(1000);
Mouse(390, 505, 60, 5, true);
GetClientDimensions(w, h);
for Pz:=0 to 25 do //Checks for the X in Game to see if logged in.
begin
wait(1000);
writeln('Waited: ' + IntToStr(Pz) + ' seconds.');
if(FindBitMapToleranceIn(TXLogOut, Px, Py, 0, 0,w-1,h-1,25))then
Break;
end;
end;

procedure WorldPageSelect(Page: Integer);
begin
Case Page of
0:
Mouse(685, 250, 0, 0, true);
1:
Mouse(690, 280, 0, 0, true);
2:
Mouse(690, 305, 0, 0, true);
3:
Mouse(690, 331, 0, 0, true);
4:
Mouse(690, 356, 0, 0, true);
5:
Mouse(690, 381, 0, 0, true);
6:
Mouse(690, 406, 0, 0, true);
7:
Mouse(690, 431, 0, 0, true);
8:
Mouse(690, 456, 0, 0, true);
end;
wait(750+random(500));

end;

procedure WorldSelection(BotNum: Integer);
begin
writeln('About to Choose Client.');
TChooseClient(BotNum, 1);
Mouse(215, 83, 2, 2, true);
writeln('First Move Mouse.');
wait(1000);
If(BotNum<3)then
begin
writeln('Going to look for world: ' + IntToStr(Players[BotNum].Banked));
case (Players[BotNum-1].Banked) of
ClickPlayButton(BotNum-1);
end;
If(BotNum>=3)then
begin
writeln('Going to look for world: ' + IntToStr(Players[BotNum].Banked));
ClickPlayButton(BotNum);
end;
end;

procedure TRestartBot(BotNum: Integer);
var
TPosX, TPosY: Integer;
begin
case TGetStatus of
'Restart': //Waits 1 second and sets the Check to False
begin //Else, Logs player in as normal using Recursion.
TUpdateStatus('Bot: ' + IntToStr(BotNum) + ' is waiting for Restart.');
wait(30000);
Players[BotNum-1].Member:=False;
If not(TGetStatus='Restart')then
begin
TRestartBot(BotNum);
end;
end;

'Terminate': //Finds the Game Session has ended
begin //Waits 10 seconds for error cehck
TUpdateStatus('Bot: ' + IntToStr(BotNum) + ' may need to be terminated.');
wait(10000);
If(TGetStatus='Terminate')then
TUpdateStatus('Bot: ' + IntToStr(BotNum) + ' has been terminated.');
if not(TGetStatus='Terminate')then
TRestartBot(BotNum);
end;

'LoggedOut': //Finds FaceBook button
begin //Logs player back in.
TUpdateStatus('Bot: ' + IntToStr(BotNum) + ' is Logged Out.');
TChooseClient(BotNum, 1);
TLogPlayerIn(BotNum);
WorldSelection(BotNum);
TPlayScripts(BotNum);
TMinimizeScreen(BotNum);
end;


'WorldSelect': //Finds World Select screen by + heart
begin //Selects World and logs in
TUpdateStatus('Bot: ' + IntToStr(BotNum) + ' is in World Select.');
TChooseClient(BotNum, 1);
WorldSelection(BotNum);
TPlayScripts(BotNum);
TMinimizeScreen(BotNum);
end;

'PlayScreen': //Finds the Play Screen by who the heck knows
begin //Goes through the Process
TUpdateStatus('Bot: ' + IntToStr(BotNum) + ' is at the Main Screen.');
TChooseClient(BotNum, 1);
WorldSelection(BotNum);
TPlayScripts(BotNum);
TMinimizeScreen(BotNum);
end;

'KillingGrots': //Finds if Killing grots by a color or another thing
begin //Exits, else logs out and restarts for world
TUpdateStatus('Bot: ' + IntToStr(BotNum) + ' is killing Grots.');
if (Players[BotNum-1].Member=False) then
begin
Players[BotNum-1].Member:=True;
TChooseClient(BotNum, 1);
PressKey(121); //F10
writeln('Turning off scripts.');
wait(1000);
writeln('Logging Player out.');
TLogPlayerOut(BotNum);
writeln('Logged Player out.');
wait(1000);
if(TGetStatus='LoggedOut')then
begin
writeln('Found Logged Out.');
TLogPlayerIn(BotNum);
end;
WorldSelection(BotNum);
writeln('Found World Select.');
TPlayScripts(BotNum);
writeln('Playing Scripts.');
TMinimizeScreen(BotNum);
end;
end;

'ScriptNotRun': //Finds if the Script is running
begin //Restarts it.
TPlayScripts(BotNum);
TMinimizeScreen(BotNum);
end;

end;
wait(1000);
end;

procedure TRunItBaby;
begin
TLoadDTMs;
ActivateClient;
repeat
TUpdateStatus('Starting loop.');
for Ti := 1 to (TCharsPlaying) do
begin
if(Ti>=TCharsPlaying+1)then
Ti:=1;
TLostCount:=0;
TMinimizeScreen(Ti);
TChooseClient(Ti, 1);
TRestartBot(Ti);
TUpdateStatus(('Restarted Bot: ' + IntToStr(Ti)));
wait(TimeBetweenChecks*1000);
end;
until(RealLostCount>=TCharsPlaying);
writeln('Script Over');

end;


begin
clearDebug();
setupSRL();
TDeclarePlayers();
SetDesktopAsClient();
TLoadDTMs;
TRunItBaby;
TFreeDTMs;
end.


Here's my source. I figure this will actually help figure out whats going on. You'll see quite a bit of hard-coded coordinates, It is just clicking things down in the task bar, and I added a custom world selection that is also hard-coded, I was in a rush, but it gets the job done. But, basically, I have 8 clients of the other script running, and this has to reselect each one, hence the TChooseClient. There's still a bunch of things I'm working on so there are parts of code that aren't used in the script yet. If you can find what causes access violations in here, it'd be greatly appreciated! My other script to run this script is basic.


program new;

var
x, y, bmp: Integer;
const
ClickLockX =1157; //Position of Play button
ClickLockY =105;
Seconds =5;
var
i: integer;
begin
SetDesktopAsClient;
Bmp := BitmapFromString(20, 3, 'meJwlzbEKgkAcgPHdvy8RLRLNooY' +
'Ejj6D+Fy1lGHv0CSEBd2lJigIiogJJ4QYXklDix0J3/rjU1V/PjuZ' +
'Ztw0n2H4Ukrb9tl1jyiqHSfJsjgMQ4yvhFSUvhXF4vkVgA2wBdgoC' +
'lrIF0FwDMMnpO37lpC6KIo8T9M0DoIAIUTIncHlksE1x+0BdgAWS5' +
'LOoujK8nEyPei663lFWeZJkkQRgzeMcVUx+NI0e4Rj/7X9A/ABayE=');
for i:=0 to 9999999999 do
begin
If(FindBitmap(Bmp, x, y))then
begin
writeln('Attempted to save Script');
MoveMouse(x+164,y+100);
ClickMouse(x+164,y+100,1);
wait(2000);
MoveMouse(331,871);
ClickMouse(331,871,2);
wait(200);
MoveMouse(300,577);
ClickMouse(300,577,1);
wait(2000);
end;
if(FindColorTolerance(x, y, 3517807, ClickLockX-10, ClickLockY-10, ClickLockX+10, ClickLockY+10, 50))then
begin
MoveMouse(ClickLockX+5,ClickLockY);
ClickMouse(ClickLockX+5,ClickLockY,1);
ClickMouse(ClickLockX+5,ClickLockY, 1);
wait(Seconds*1000);
end;
end;
end.

Olly

2013-05-04 11:33:14

Why don't you use SMART? would make all this alot easier