SRL Archive - SRL Suggestions

OptionsMenuOpen


Press Play

2012-01-15 20:19:59

A function for text.simba
(*
OptionsMenuOpen
~~~~~~~~~~~

.. code-block:: pascal

function OptionsMenuOpen: Boolean;

Returns true if the option menu is open.

.. note::

by -daazndagger-

Example:

.. code-block:: pascal

if (OptionsMenuOpen) then
ChooseOption('');

*)
function OptionsMenuOpen: Boolean;
var
cho, fx, fy: Integer;
begin
{Writeln(IntToStr(CountColor(9812166, MCX1, MCY1, MCX2, MCY2)));
Result := CountColor(9812166, MCX1, MCY1, MCX2, MCY2) >= 309; }

{cho := BitmapFromString(22, 20, 'meJyLysyJogwp6hpSiKQ0NClFqp' +
'QiUQUVCpGIrAKFSFBKduqOY3AE5EIQGhcPgqjkFZMEIlxs/Aiikkt' +
'QBA3hEideJakmsPPwoyHkwEFTgCYOYTBzcqAhZHH8bAhiYmNHQ8ji' +
'+NnUcgMjOxsQkcdGM4qgGzDVQ0yjBGGGAKmI8vLBySOUQgQADJYpkw=='); }

cho := BitmapFromString(22, 6, 'meJybuuPY1B3HGNnZgGgqWWxmTg4' +
'IA86FIGQuVim4IMQ0ShDcZLKRlIYmhcjJI5RCBAA48FJl');
Result := FindBitmap(cho, fx, fy);
FreeBitmap(cho);
end;

I believe that when you right-click and get the Options Menu, the colours at the top of the menu (ie. 'Choose Option') are static (don't change). This part also has no transparency either. I think this would be a good function to have in SRL!

The code above shows the different methods I used and my thought process:
  • Firstly, I noted that the text 'Choose Option' is all the one colour, so I decided to use CountColor.
  • Obviously, this would be unreliable if there there is the same colour on screen elsewhere!
  • So I changed it to a bitmap.. Then reduced the size of the bitmap :)
  • I would have done a text-check instead but I wasn't sure how to go about it :( I tried using multiple things but I believe that all the other functions take into account shadow? This text has no shadow.
I have tested the function multiple times. Logged out/closed client/re-loaded/changed worlds etc.. And it always returns true/false respectively :)


EDIT: I think the reason I made this was because I don't like the way the Withdraw function re-right-clicks on an item in the bank when it wants to "Withdraw-X". It's very un-human like and yeahh :p So, I was thinking this too:
function WithdrawEx(Col, Row, Amount: Integer; Uptexts: TStringArray): Boolean;
var
BBox: TBox;
X, Y: Integer;
begin
Result := False;
FixBank;

BBox := BankIndexToMSBox(BankPointToBankIndex(Point(Col, Row)));
GetMousePos(X, Y);
if (not PointInBox(Point(X, Y), BBox)) then
MouseBox(BBox.X1 + 5, BBox.Y1 + 5, BBox.X2 - 5, BBox.Y2 - 5, mouse_move);

if (Length(Uptexts) > 0) then
if (not WaitUptextMulti(Uptexts, 500)) then
Exit;

if (Amount = 1) then
ClickMouse2(mouse_left)
else
ClickMouse2(mouse_right);
if (Amount = 1) then
begin
Result := True;
Wait(RandomRange(250, 550));
Exit;
end;

if (Amount = -1) then
Result := WaitOptionMulti(['Withdraw-All but', 'l b'], 300)
else if (Amount = 0) then
Result := WaitOptionMulti(['Withdraw-All', 'w-A'], 300)
else
Result := WaitOptionMulti(['Withdraw-' + IntToStr(Amount), 'w-' + IntToStr(Amount)] , 300);

if (not (Result)) and (Amount > 0) then
begin
if not OptionsMenuOpen then
MouseBox(BBox.X1 + 5, BBox.Y1 + 5, BBox.X2 - 5, BBox.Y2 - 5, mouse_right);
if WaitOptionMulti(['Withdraw-X', 'w-X'], 500) then
begin
X := GetSystemTime + 10000;
while (X >= GetSystemTime) and (not (InRange(CountColor(0, 250, 396, 307, 410), 155, 165))) do
Wait(50);
Wait(RandomRange(75, 400));
TypeSend(IntToStr(Amount));
Result := True;
end;
end;
end;

Coh3n

2012-01-16 16:03:01

I think you can just use this and it would serve the same purpose would it not?

if (OptionsExist(['Choose Option'], false)) then
Writeln('Choose Option box is open');

Press Play

2012-01-16 17:06:34

I think I tried that and it didn't work :S. But if that does work, do you think it can be added into the library? Or even if it doesn't, can you change the Withdraw(); function so it does not re-click? It irritates me :)

Coh3n

2012-01-16 20:39:53

I'm not going to add that to the library. You can just call it in your script. It's only one line. ;) And it should work, but I'll test it out. Also, yeah I'll fix Withdraw(). I've been meaning to do that for a while.

E: It may take a bit longer than I thought as there's no easy way of doing it that I can see. I may have to edit ChooseOptionMultiEx as it moves the mouse away if the option you're looking for doesn't exist.

E2: Fixed for the next version.

Press Play

2012-01-17 02:34:16

Thanks Cohen!

EDIT: How long until SRL pushes the update? Do you reckon you can post me the code for now? I'd like to implement the test straight away :p I'm anxious to use it ahah.

Coh3n

2012-01-17 13:49:14

I pushed it last night. :) Look at WithdrawEx to see how I checked if the Choose Option menu was open.