Jump to content

Get the fonts used in RS?


Recommended Posts

Posted (edited)

If you have the actual font file, it would be easy to determine the dimensions of any given string, using fontmetrics or glyph vectors. A Graphics object should provide access to these.

 

If you just want to calculate an area in the rs right-click menu, you can easily do so by using the MenuAPI class

Edited by FrostBug
Posted

hmm I never tried this before. 

For what purpose would you need this ?

 

Khaleesi

I would like to write my own right click - interact method using this as the one in OSBot seems to be too fast and misclicks a lot.

 

If you have the actual font file, it would be easy to determine the dimensions of any given string, using fontmetrics og glyph vectors. A Graphics object should provide access to these.

 

If you just want to calculate an area in the rs right-click menu, you can easily do so by using the MenuAPI class

Thank you, will use MenuAPI. I know how to measure font widths/heights, that's why I was asking how to get the font :P

 

Posted

I would like to write my own right click - interact method using this as the one in OSBot seems to be too fast and misclicks a lot.

 

Thank you, will use MenuAPI. I know how to measure font widths/heights, that's why I was asking how to get the font tongue.png

I love the missclicks :) You know your script is well written once it can handle missclicks. imo it doesn't missclick that often.

Just look up the current implementation and try to 'improve' it, no need to do fancy stuff with fonts you got all the widget sizes.

Posted

I would like to write my own right click - interact method using this as the one in OSBot seems to be too fast and misclicks a lot.

 

Thank you, will use MenuAPI. I know how to measure font widths/heights, that's why I was asking how to get the font tongue.png

 

To get the rectangle for a menu item (Eg. "Walk here"), you can do something like this:

 

getMenuAPI().getOptionRectangle(getMenuAPI().getMenuIndex(null, new String[]{"Walk here"});

I don't remember if it allows null for entity names, though. If not you can just iterate the Option list to find the index of whatever option you want.

 

Posted

I would like to write my own right click - interact method using this as the one in OSBot seems to be too fast and misclicks a lot.

 

Thank you, will use MenuAPI. I know how to measure font widths/heights, that's why I was asking how to get the font tongue.png

 

Check out the "Menu" class. Pretty sure you can get a bounding rectangle around the action you need.

 

Khaleesi 

Posted

I love the missclicks smile.png You know your script is well written once it can handle missclicks. imo it doesn't missclick that often.

Just look up the current implementation and try to 'improve' it, no need to do fancy stuff with fonts you got all the widget sizes.

My script can handle misclicks just fine, but it does it and that doesn't help (+ it sometimes is way too fast imo)

 

To get the rectangle for a menu item (Eg. "Walk here"), you can do something like this:

 

getMenuAPI().getOptionRectangle(getMenuAPI().getMenuIndex(null, new String[]{"Walk here"});

I don't remember if it allows null for entity names, though. If not you can just iterate the Option list to find the index of whatever option you want.

 

Here's the implementation I thought of:

public boolean interactWith(Entity e, String action) throws InterruptedException {
		if (e == null) {
			return false;
		}
		
		while (!getMouse().isOnCursor(e)) { e.hover(); sleep(rand(450, 750)); } //hover
		while (!getMenuAPI().isOpen()) { getMouse().click(true); sleep(rand(150, 450)); } //open interface
		sleep(rand(150, 450));
		
		List<Option> options = getMenuAPI().getMenu();
		int rectIndex = -1;
		
		for (int i = 0; i < options.size(); i++) {
			Option o = options.get(i);
			String s = o.action;
			if (s.equals(action)) {
				rectIndex = i;
				break;
			}
		}
		
		if (rectIndex == -1) {
			return false;
		}
		
		Rectangle optionRect = getMenuAPI().getOptionRectangle(rectIndex);
		
		int height = optionRect.height;
		int startX = optionRect.x;
		int startY = optionRect.y;
		int width = optionRect.width;
		int endX = startX + width;
		int endY = startY + height;
		
		//2px bounds incase the bounding boxes are fucked
		int randX = getRandom(startX + 1, endX - 1);
		int randY = getRandom(startY + 1, endY - 1);
		
		while (!(getMouse().getPosition() == new Point(randX, randY))) { getMouse().move(randX, randY); sleep(rand(450, 750)); } //move to option
		sleep(rand(150, 450));
		while (getMenuAPI().isOpen()) { getMouse().click(false); sleep(rand(750, 1150)); } //click
		
		return true;
	}

Could definitely be improved, however I cannot test and currently this seems like the best way.

Posted (edited)

My script can handle misclicks just fine, but it does it and that doesn't help (+ it sometimes is way too fast imo)

 

Here's the implementation I thought of:

public boolean interactWith(Entity e, String action) throws InterruptedException {
		if (e == null) {
			return false;
		}
		
		while (!getMouse().isOnCursor(e)) { e.hover(); sleep(rand(450, 750)); } //hover
		while (!getMenuAPI().isOpen()) { getMouse().click(true); sleep(rand(150, 450)); } //open interface
		sleep(rand(150, 450));
		
		List<Option> options = getMenuAPI().getMenu();
		int rectIndex = -1;
		
		for (int i = 0; i < options.size(); i++) {
			Option o = options.get(i);
			String s = o.action;
			if (s.equals(action)) {
				rectIndex = i;
				break;
			}
		}
		
		if (rectIndex == -1) {
			return false;
		}
		
		Rectangle optionRect = getMenuAPI().getOptionRectangle(rectIndex);
		
		int height = optionRect.height;
		int startX = optionRect.x;
		int startY = optionRect.y;
		int width = optionRect.width;
		int endX = startX + width;
		int endY = startY + height;
		
		//2px bounds incase the bounding boxes are fucked
		int randX = getRandom(startX + 1, endX - 1);
		int randY = getRandom(startY + 1, endY - 1);
		
		while (!(getMouse().getPosition() == new Point(randX, randY))) { getMouse().move(randX, randY); sleep(rand(450, 750)); } //move to option
		sleep(rand(150, 450));
		while (getMenuAPI().isOpen()) { getMouse().click(false); sleep(rand(750, 1150)); } //click
		
		return true;
	}

Could definitely be improved, however I cannot test and currently this seems like the best way.

 

This doesn't really solve the main misclick issues, though.

Just like the method in the API, it lacks a check for whether or not the menu is still open before clicking (At least the API method used to lack it. I am not 100% certain that it still does). Due to the nature of the mouse algo, the path taken to the option can sometimes lead to the mouse getting too far away from the menu, closing it on the way.

 

I made some API methods for interaction with this last check about a year ago, will probs post in snipper section when I get home

 

Offtopic, using while loops without any form of timeout is generally a bad idea

 

Edited by FrostBug
Posted

This doesn't really solve the main misclick issues, though.

Just like the method in the API, it lacks a check for whether or not the menu is still open before clicking (At least the API method used to lack it. I am not 100% certain that it still does). Due to the nature of the mouse algo, the path taken to the option can sometimes lead to the mouse getting too far away from the menu, closing it on the way.

 

I made some API methods for interaction with this last check about a year ago, will probs post in snipper section when I get home

 

Offtopic, using while loops without any form of timeout is generally a bad idea

 

There is a check to make sure the mouse is at the random position (which is within the bounding box). There is also a check to see if the menu is open before it clicks.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...