Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

getMouse.click not working

Featured Replies

I'm trying to use getMouse().click but it doesn't seem to be clicking when I want it to.

My code is as follows:

for (i = 0; i < 28; i++) {
	if (InventorySlotDestination.getSlot(i).contains(getMouse().getPosition())) {
		if (getMouse().click(false)) {
			i++;
			sleep(random(100, 125));
		}
	} else {
		Rectangle rect = InventorySlotDestination.getSlot(i);
		getMouse().move(rect.x + (rect.width / 2), rect.y + (rect.height / 2));
		sleep(random(100, 125));
	}
}

Basically I'm just trying to click on all items in my inventory, my mouse moves through the inventory as intended but doesn't click on anything.

I don't want to use inventory.interact() as that doesn't serve the right purpose for what I want to do.

Edited by d0zza

How do you expect to click something when there's no action after a condition?

  • Author
4 minutes ago, Charlotte said:

How do you expect to click something when there's no action after a condition?

This line here:
if (getMouse().click(false)) {

should be clicking the mouse, just because I have it in an if statement doesn't mean its not going to do anything. getMouse().click() is a boolean function that returns true if the mouse is clicked or false if it isn't.

39 minutes ago, d0zza said:

This line here:
if (getMouse().click(false)) {

should be clicking the mouse, just because I have it in an if statement doesn't mean its not going to do anything. getMouse().click() is a boolean function that returns true if the mouse is clicked or false if it isn't.

Well it should be clicking correctly, most likely the first if statement is wrong.

But Im guessing you want it to shif click drop, which osbot already does if you enable it in game :b

  • Author
2 hours ago, Vilius said:

Well it should be clicking correctly, most likely the first if statement is wrong.

But Im guessing you want it to shif click drop, which osbot already does if you enable it in game :b

Oh fuck me I know why, I should be using a while loop, not a for loop

Edited by d0zza

try this

for (int i = 0; i < 28; i++) {
    if (getMouse().click(getInventory().getMouseDestination(i))) {
        sleep(random(100, 125));
    }
}

you can decrement i if it fails to click the slot, but that may produce weird results

also may want to check if there's an item at slot unless you want it to click empty slots

It doesn't click because you're wasting your index on moving to the slot :P then the next loop it will come in the first else again, moving to the next...but the first if statement never gets executed...
 

for (i = 0; i < 28; i++) {
	if (InventorySlotDestination.getSlot(i).contains(getMouse().getPosition())) {
		//...never gets in here, because this is the next slot...why would the mouse already be there?
	} else {
		//...always executes this to move to the next
	}
}

so basically you want something like

for (i = 0; i < 28; i++) {
	if (!InventorySlotDestination.getSlot(i).contains(getMouse().getPosition())) {
		Rectangle rect = InventorySlotDestination.getSlot(i);
		if (getMouse().move(rect.x + (rect.width / 2), rect.y + (rect.height / 2))) {
			sleep(random(100, 125));
		}
	}

	if (InventorySlotDestination.getSlot(i).contains(getMouse().getPosition())) {
		if (getMouse().click(false)) {
			// i++; this one isn't necessary unless you want to skip
			// items
			sleep(random(100, 125));
		}
	}
}

But anyways, as Stimpack already said, it's easier to let the osbot api do all that for you by using 

getMouse().click(getInventory().getMouseDestination(i))

Edited by Reveance

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.