SRL Archive - SRL Archives

Right Click Menu


Iamadam

2006-05-29 07:34:22

Hey hey
Well here's what I've been working on…
[PHP]
program RightClickMenu;
{.include SRL\Srl.scar}
{
Author - Iamadam

function isOptionboxOpen : boolean -
—Returns true if the 'Choose Option' box is visible on screen.

function getChooseCoords(X : boolean) : Integer
—Returns the X coord of the box if X is true, otherwise returns the Y.

function getNumberOfOptions : Integer;
—Returns the number of options listed in the option box.

function getSelectedOption : Integer;
—Returns the index of the selected option (where 1 is the first)
—Returns -1 if no option is selected.

function getCoordsOfSelected(X : Boolean) : Integer;
—Returns the X Coordinate of the selected text in an option box if
—left is set to true. Otherwise, returns the Y Coordinate.

procedure selectOption(index : Integer);
—If an option box is open, selects the option represented by 'index'
—(where 1 is the first option)

procedure selectRandomOption;
—If an option box is open, selects a random option (where 1 is the first option)

procedure examine;
—If an option box is open, will examine the object.
—If examine is not an option, it will either click something wrong ;)
}
function isOptionboxOpen : boolean;
var x,y,Choose : Integer;
begin
Choose := BitmapFromString(31, 13, 'z78DA333018DAC0D4C5D4' +
'C4C41C99C4AF66B0B919BF0B07A7CBC9F3E3A8CBE9E97262F2057' +
'E5D94ABA7C4E5E4E50BEA8A53925A465D4EB9F8E07721B56A2252' +
'4DA66E8E1E05F404002D5BD75E');
if(findBitmap(Choose,x,y)) then
result := true;
end;

function getChooseCoords(_X : boolean) : Integer;
var Choose,x,y : Integer;
begin
Choose := BitmapFromString(31, 13, 'z78DA333018DAC0D4C5D4' +
'C4C41C99C4AF66B0B919BF0B07A7CBC9F3E3A8CBE9E97262F2057' +
'E5D94ABA7C4E5E4E50BEA8A53925A465D4EB9F8E07721B56A2252' +
'4DA66E8E1E05F404002D5BD75E');
findBitmap(Choose,x,y);
if(_x) then
result := x
else
result := y;
end;



function getNumberofOptions : Integer;
var x, y, x1, y1, Can, Can2, Choose : Integer;
begin
Can := BitmapFromString(15, 12, 'z78DA33753135313137A523E98' +
'601A86BA60118506E3EA699100091C514A1C4645A842DF126BBE1' +
'0094988C2BF428377930B819533D2E11FC2EC19F3E317D872BD51' +
'1131A98A40106205E2500217DF613');
Can2 :=BitmapFromString(15, 10, 'z78DA337531353131374522DD8' +
'0C0C0009934C550432A896C1A04506E3EA699100091C514A1C464' +
'CA4380129331630433DC48351957E8619A4F5D37536232F16EC65' +
'48F4B04BF4BF0A7524C7FE14A75F8430300D6A5C8DE');

Choose := BitmapFromString(31, 13, 'z78DA333018DAC0D4C5D4' +
'C4C41C99C4AF66B0B919BF0B07A7CBC9F3E3A8CBE9E97262F2057' +
'E5D94ABA7C4E5E4E50BEA8A53925A465D4EB9F8E07721B56A2252' +
'4DA66E8E1E05F404002D5BD75E');
if(findBitmap(Choose,x,y)) then
begin
if(findBitmap(Can,x1,y1)) then
result := (y1 - y)/15
else
begin
findBitmap(Can2,x1,y1);
result := (y1 - y)/15;
end;
end;
end;

function getSelectedOption : Integer;
var x, y, x1, y1, noOfOptions : Integer;
begin
x := getChooseCoords(true);
y := getChooseCoords(false);
noOfOptions := getNumberOfOptions;
if(findColorTolerance(x1, y1, 65535, x-10, y, x+10, y + noOfOptions * 17 + 10, 5)) then
begin
result := (y1 - y)/15;
exit;
end
else
result := -1;
end;

function getCoordsOfSelected(_X : Boolean) : Integer;
var y, selected : Integer;
begin
if(_X) then
result := getChooseCoords(true)
else
begin
y := getChooseCoords(false);
selected := getSelectedOption();
if(selected > 0) then
begin
result := y + selected * 15;
end
else
result := -1;
end;
end;

procedure selectOption(index : Integer);
var x, y, x1, y1 : Integer;
begin
if(getNumberOfOptions < index) or (index < 1) then
exit
else
begin
getMousePos(x1, y1);
if(getSelectedOption = index) then
Mouse(x1, y1, 0, 0, true)
else
begin
x := getChooseCoords(true);
y := getChooseCoords(false);
Mouse(x + random(30) + 1, (y + (15 * index)) + 2 + random(10),0,0,true);
end;
end;
end;

procedure selectRandomOption();
var opts :Integer;
begin
opts := getNumberOfOptions();
selectOption(random(opts)+1);
end;

procedure examine();
begin
selectOption(getNumberOfOptions()-1)
end;

[/PHP]
And yes I do have a sinking feeling that this has all been done and is in SRL, but hey, its something anyway ;)

inferno

2006-05-29 07:47:35

Good work Iamadam. Lots of useful functions. :)

With the getChooseCoords function the user would have to use it twice to get both the X and Y coordinates of the box. Also you use the variables X and Y, in includes it is best not to use these in case it messes up the users script. These can be solved by changing it to this:

procedure getChooseCoords(Va : TPoint);
var Choose, dx, dy : Integer;
begin
Choose := BitmapFromString(31, 13, 'z78DA333018DAC0D4C5D4' +
'C4C41C99C4AF66B0B919BF0B07A7CBC9F3E3A8CBE9E97262F2057' +
'E5D94ABA7C4E5E4E50BEA8A53925A465D4EB9F8E07721B56A2252' +
'4DA66E8E1E05F404002D5BD75E');
if(findBitmap(Choose, dx, dy))then
begin
va.x := dx;
va.y := dy;
end;
end;
Through this both the X and Y co-ords would be stored in a TPoint variable specified by the user.

Iamadam

2006-05-29 08:07:19

Yeah, I was thinking that. The thing is, alot of people don't understand TPoints. I guess I'm used to writing for communities that aren't as smart ;)
Thanks for the comment :)

Cheesehunk

2006-05-29 10:51:45

Good job! I was going to make a lot of Procedures very similiar to thism I was thinking about it last night, but you already made them!

Very useful, good job, when these are added to SRL, I will be using them.

Bebe

2006-05-29 12:02:10

Very nice work :)