AlpacaLibary  1.63
A closed source C++ bot for OSRS
Menu Namespace Reference

A namespace containing various functions for the right-click menu. More...

Functions

bool IsOpen ()
 
bool Open ()
 Opens the menu by right-clicking wherever the mouse currently is. More...
 
bool Close ()
 
std::int32_t GetCount ()
 
bool OptionsValid (std::int32_t MenuCount, const std::vector< std::string > &RawActions, const std::vector< std::string > &RawTargets)
 Attempts to verify the order of the passed menu actions and targets. More...
 
std::vector< std::string > GetActions ()
 Get the menu actions. More...
 
std::vector< std::string > GetTargets ()
 Get the menu targets. More...
 
std::vector< std::string > GetOptions ()
 Get the menu options. More...
 
std::vector< std::pair< std::string, std::string > > GetSplitOptions ()
 Get the menu options split into pairs instead of whole strings. More...
 
std::int32_t IndexOf (const std::string &Option)
 Get the index of the found option. More...
 
std::int32_t IndexOf (const std::vector< std::string > &Options)
 Get the index of the first found option. More...
 
std::tuple< std::int32_t, std::string, std::string > FindOption (std::uint32_t Index)
 Looks for a menu option at the passed index, and returns information about the found option. More...
 
std::tuple< std::int32_t, std::string, std::string > FindOption (const std::string &Option)
 Looks for a menu option containing the passed Option, and returns information about the found option. More...
 
std::tuple< std::int32_t, std::string, std::string > FindOption (const std::vector< std::string > &Options)
 Looks for a menu option containing the passed Option, and returns information about the found option. More...
 
std::vector< std::tuple< std::int32_t, std::string, std::string > > FindOptions (const std::string &Option)
 Looks for a menu option containing the passed Option, and returns information of all options that were found. More...
 
std::vector< std::tuple< std::int32_t, std::string, std::string > > FindOptions (const std::vector< std::string > &Options)
 Looks for a menu option containing the passed Option, and returns information of all options that were found. More...
 
bool Contains (const std::string &Option)
 Returns true if the menu contains the passed Option. More...
 
bool Contains (const std::vector< std::string > &Options)
 Returns true if the menu contains at least one of the passed Options. More...
 
bool WaitContains (std::uint32_t Duration, std::uint32_t Step, const std::string &Option)
 Waits until the menu contains the passed option. More...
 
bool WaitContains (std::uint32_t Duration, std::uint32_t Step, const std::vector< std::string > &Options)
 Waits until the menu contains at leaset one of the passed options. More...
 
bool Select (std::int32_t Index, bool CloseMenu=true)
 Selects the menu option by the passed index if the menu is open. More...
 
bool Select (const std::string &Option, bool CloseMenu=true)
 Selects the passed menu option if the menu is open. More...
 
bool Select (const std::vector< std::string > &Options, bool CloseMenu=true)
 Selects the first found option in the menu. More...
 
std::vector< BoxGetOptionBoxes ()
 Get the array of menu option boxes, each box is a menu option. More...
 
Box GetBox ()
 

Detailed Description

A namespace containing various functions for the right-click menu.

Function Documentation

◆ Close()

bool Menu::Close ( )

◆ Contains() [1/2]

bool Menu::Contains ( const std::string &  Option)

Returns true if the menu contains the passed Option.

Parameters
OptionMenu option to look for, the more specific the option, the more specific the option, the more accurate the result will be
Returns
true if the found index is valid (Index >= 0)
See also
Menu::IndexOf(const std::string& Option)
Warning
The result can rarely be inaccurate if the menu isn't open before calling this function

◆ Contains() [2/2]

bool Menu::Contains ( const std::vector< std::string > &  Options)

Returns true if the menu contains at least one of the passed Options.

Parameters
%OptionsMenu options to look for, returns on first option found, the more specific the options, the more accurate the result will be
Returns
true if the found index is valid (Index >= 0)
See also
Menu::IndexOf(const std::string& Options)
Warning
The result can rarely be inaccurate if the menu isn't open before calling this function

◆ FindOption() [1/3]

std::tuple<std::int32_t, std::string, std::string> Menu::FindOption ( const std::string &  Option)

Looks for a menu option containing the passed Option, and returns information about the found option.

Parameters
OptionMenu option to look for, the more specific, the more accurate the result will be
Returns
std::tuple<bool, std::string, std::string> std::int32_t [0] = Index of the option that was found, -1 if the option wasn't found std::string [1] = Action that was found std::string [2] = Target that was found
See also
Menu::IndexOf(const std::string& Option)
Warning
The result can rarely be inaccurate if the menu isn't open before calling this function

◆ FindOption() [2/3]

std::tuple<std::int32_t, std::string, std::string> Menu::FindOption ( const std::vector< std::string > &  Options)

Looks for a menu option containing the passed Option, and returns information about the found option.

Parameters
%OptionsMenu options to look for, returns on first option found, the more specific the options, the more accurate the result will be
Returns
std::tuple<bool, std::string, std::string> std::int32_t [0] = Index of the option that was found, -1 if the option wasn't found std::string [1] = Action that was found std::string [2] = Target that was found
See also
Menu::IndexOf(const std::string& Options)
Warning
The result can rarely be inaccurate if the menu isn't open before calling this function

◆ FindOption() [3/3]

std::tuple<std::int32_t, std::string, std::string> Menu::FindOption ( std::uint32_t  Index)

Looks for a menu option at the passed index, and returns information about the found option.

Parameters
IndexThe index of the menu option to look at
Returns
std::tuple<bool, std::string, std::string> std::int32_t [0] = Index of the option that was found, -1 if the option wasn't found std::string [1] = Action that was found at index std::string [2] = Target that was found at index
See also
Menu::IndexOf(const std::string& Option)
Warning
The result can rarely be inaccurate if the menu isn't open before calling this function

◆ FindOptions() [1/2]

std::vector<std::tuple<std::int32_t, std::string, std::string> > Menu::FindOptions ( const std::string &  Option)

Looks for a menu option containing the passed Option, and returns information of all options that were found.

Parameters
OptionMenu option to look for, the more specific the option, the more accurate the result will be
Returns
std::vector<std::tuple<std::int32_t, std::string, std::string>> std::int32_t [0] = Index of the option that was found, -1 if the option wasn't found std::string [1] = Action that was found std::string [2] = Target that was found
Warning
The result can rarely be inaccurate if the menu isn't open before calling this function
See also
Menu::IndexOf(const std::string& Option)

◆ FindOptions() [2/2]

std::vector<std::tuple<std::int32_t, std::string, std::string> > Menu::FindOptions ( const std::vector< std::string > &  Options)

Looks for a menu option containing the passed Option, and returns information of all options that were found.

Parameters
%OptionsMenu options to look for, if the option is found within the menu options, it'll be added to the result array, the more specific the options, the more accurate the result will be
Returns
std::vector<std::tuple<std::int32_t, std::string, std::string>> std::int32_t [0] = Index of the option that was found, -1 if the option wasn't found std::string [1] = Action that was found std::string [2] = Target that was found
See also
Menu::IndexOf(const std::string& Options)
Warning
The result can rarely be inaccurate if the menu isn't open before calling this function

◆ GetActions()

std::vector<std::string> Menu::GetActions ( )

Get the menu actions.

Actions are almost always the very first word in a menu option 'Use' - action 'gold bar' - target 'Attack' - action 'Guard (level-21)' - target

Returns
std::vector<std::string> array of menu actions
Warning
The result can rarely be inaccurate if the menu isn't open before calling this function

◆ GetBox()

Box Menu::GetBox ( )
Returns
Box representing the full menu, returns a null box if the menu isn't open

◆ GetCount()

std::int32_t Menu::GetCount ( )

◆ GetOptionBoxes()

std::vector<Box> Menu::GetOptionBoxes ( )

Get the array of menu option boxes, each box is a menu option.

Returns
std::vector<Box> array of the menu option boxes, returns an empty array if the menu isn't open

◆ GetOptions()

std::vector<std::string> Menu::GetOptions ( )

Get the menu options.

'Use' - action 'gold bar' - target 'Attack' - action 'Guard (level-21)' - target 'Use gold bar' - option 'Attack Guard (level-21)' - option

Returns
std::vector<std::string> array of menu options
Warning
The result can rarely be inaccurate if the menu isn't open before calling this function

◆ GetSplitOptions()

std::vector<std::pair<std::string, std::string> > Menu::GetSplitOptions ( )

Get the menu options split into pairs instead of whole strings.

'Use' - action 'gold bar' - target 'Attack' - action 'Guard (level-21)' - target 'Use gold bar' - option 'Attack Guard (level-21)' - option first is the action, second is the target

Returns
std::vector<std::pair<std::string, std::string>>
Warning
The result can rarely be inaccurate if the menu isn't open before calling this function

◆ GetTargets()

std::vector<std::string> Menu::GetTargets ( )

Get the menu targets.

Targets are almost always everything after the action 'Use' - action 'gold bar' - target 'Attack' - action 'Guard (level-21)' - target

Returns
std::vector<std::string> array of menu targets
Warning
The result can rarely be inaccurate if the menu isn't open before calling this function

◆ IndexOf() [1/2]

std::int32_t Menu::IndexOf ( const std::string &  Option)

Get the index of the found option.

This function will find the first menu option containing the string 'Option' This means passing 'Att' or 'Attack' will return the first found menu option containing 'Att' or 'Attack' If you want to find a very specific menu option, the more the 'Option' string contains, the more specific it'll be

Say for example, you want to attack a guard whose level is 40, and on this one tile, there's 5 different guards, all with different levels If you pass 'Attack' as the 'Option' to look for, it'll select the very first guard, regardless of level. If you pass 'Attack Guard (level-40)' as the 'Option' to look for, it'll attack the guard whose level is 40.

Parameters
OptionMenu option to look for, can be very specific, or very lenient
Returns
std::int32_t The index of the first found option, -1 if the option wasn't found
Note
Notice that 'Attack Guard (level-40)' has a double space after 'Guard', menu options can vary, in this case the menu option i'm looking for has a double space after 'Guard'.
Warning
The result can rarely be inaccurate if the menu isn't open before calling this function

◆ IndexOf() [2/2]

std::int32_t Menu::IndexOf ( const std::vector< std::string > &  Options)

Get the index of the first found option.

This function will return the first found index, of the first found option. This function is just Menu::IndexOf(const std::string& Option), but instead of looking for one single option, this function looks for multiple

Parameters
OptionsMenu options to look for, returns on first option found, the more specific the options, the more accurate the result will be
Returns
std::int32_t The index of the first found option, -1 if the option wasn't found
See also
Menu::IndexOf(const std::string& Option)
Warning
The result can rarely be inaccurate if the menu isn't open before calling this function

◆ IsOpen()

bool Menu::IsOpen ( )

◆ Open()

bool Menu::Open ( )

Opens the menu by right-clicking wherever the mouse currently is.

Returns
true if the menu is currently open or opened by right clicking
false if WaitFunc fails - WaitFunc(1000, 100, Menu::IsOpen, true);

◆ OptionsValid()

bool Menu::OptionsValid ( std::int32_t  MenuCount,
const std::vector< std::string > &  RawActions,
const std::vector< std::string > &  RawTargets 
)

Attempts to verify the order of the passed menu actions and targets.

Returns
true if the passed menu actions and targets are in the correct order
Note
This isn't a guarantee, but testing shows near zero failure rate

◆ Select() [1/3]

bool Menu::Select ( const std::string &  Option,
bool  CloseMenu = true 
)

Selects the passed menu option if the menu is open.

Parameters
OptionMenu option to look for, the more specific the option, the more accurate the result will be
CloseMenuClose the menu if the function fails by using Menu::Close(), true by default
Returns
true if the function selected the option by option
false if the menu isn't open, the found option was invalid, the option box is off-screen, or the WaitFunc failed - WaitFunc(1000, 100, Menu::IsOpen, false)
See also
Menu::IndexOf(const std::string& Option)

◆ Select() [2/3]

bool Menu::Select ( const std::vector< std::string > &  Options,
bool  CloseMenu = true 
)

Selects the first found option in the menu.

Parameters
%OptionsMenu options to look for, uses the first option found, the more specific the options, the more accurate the result will be
CloseMenuClose the menu if the function fails using Menu::Close(), true by default
Returns
true if the function selected the option by the first found option
false if the menu isn't open, the found option was invalid, the option box is off-screen, or the WaitFunc failed - WaitFunc(1000, 100, Menu::IsOpen, false)
See also
Menu::IndexOf(const std::string& Options)

◆ Select() [3/3]

bool Menu::Select ( std::int32_t  Index,
bool  CloseMenu = true 
)

Selects the menu option by the passed index if the menu is open.

Parameters
IndexThe index of the option
CloseMenuClose the menu if the function fails by using Menu::Close(), true by default
Returns
true if the function selected the option by index
false if the menu isn't open, the passed index is invalid (-1), the option box is off-screen, or the WaitFunc failed - WaitFunc(1000, 100, Menu::IsOpen, false)

◆ WaitContains() [1/2]

bool Menu::WaitContains ( std::uint32_t  Duration,
std::uint32_t  Step,
const std::string &  Option 
)

Waits until the menu contains the passed option.

Parameters
DurationHow long to wait until returning
StepHow long to wait until it checks the menu options
OptionMenu option to look for, the more specific the option, the more accurate the result will be
Returns
true if the found index is valid (Index >= 0)
See also
Menu::IndexOf(const std::string& Option)
Menu::Contains(const std::string& Option)

◆ WaitContains() [2/2]

bool Menu::WaitContains ( std::uint32_t  Duration,
std::uint32_t  Step,
const std::vector< std::string > &  Options 
)

Waits until the menu contains at leaset one of the passed options.

Parameters
DurationHow long to wait until returning
StepHow long to wait until it checks the menu options
%OptionsMenu options to look for, returns on first option found, the more specific the options, the more accurate the result will be
Returns
true if the found index is valid (Index >= 0)
See also
Menu::IndexOf(const std::string& Options)
Menu::Contains(const std::string& Options)