June 4, 201510 yr I want to be able to measure the height of the fonts used in RS. Is this possible? For example, measuring the height of an item within a context menu to get an estimate for where my mouse should be.
June 4, 201510 yr 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 June 4, 201510 yr by FrostBug
June 4, 201510 yr Author 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
June 4, 201510 yr chat (old) http://www.fonts2u.com/runescape-chat-font-regular.font chat and interfaces (old and current) https://sites.google.com/site/interactiverune/kits/fonts includes npc contact fonts also. you're welcome
June 4, 201510 yr 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 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.
June 4, 201510 yr 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 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.
June 4, 201510 yr 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 Check out the "Menu" class. Pretty sure you can get a bounding rectangle around the action you need. Khaleesi
June 4, 201510 yr Author 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. 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.
June 4, 201510 yr 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 June 4, 201510 yr by FrostBug
June 4, 201510 yr Author 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.
June 4, 201510 yr 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. But not a check for e.exists(), which might be an issue in the first while loop :p
June 4, 201510 yr Author But not a check for e.exists(), which might be an issue in the first while loop Will add that too.
Create an account or sign in to comment