Jump to content

sending a shift+right-click to an inventory-item


Recommended Posts

Hey i'm trying to write a plugin that will open crates and clams while fishing.
Sadly i have no idea how to send a shift+right-click to an item.
Does anyone have an idea how to do that ?

this does not work:

wManager.Wow.Helpers.ItemsManager.UseItem(item.Name);
Lua.LuaDoString("LootButton1:Click()");

this might work but i don't know how to continue:

foreach (WoWItem item in items) 
	{
		if (item.Name.Equals("Heavy Crate") || item.Name.Equals("Big-mouth Clam"))
		{
			wManager.Wow.Helpers.Bag.OpenAllBags();
			List<int> bagAndSlot = wManager.Wow.Helpers.Bag.GetItemContainerBagIdAndSlot(item.Name);
			...
			x=?
			y=?
			robotManager.Helpful.Keyboard.DownKey(wManager.Wow.Memory.WowMemory.Memory.WindowHandle, System.Windows.Forms.Keys.Shift);
			robotManager.Helpful.Mouse.ClickRight();
			robotManager.Helpful.Keyboard.UpKey(wManager.Wow.Memory.WowMemory.Memory.WindowHandle, System.Windows.Forms.Keys.Shift);
			wManager.Wow.Helpers.Bag.CloseAllBags();
		}

	}

 

Link to comment
Share on other sites

Hello, since you are using vanilla i assume the method doesn't work correctly but i'm not sure("DoString" is obfuscated).

You also can't use the "/use <item>" it wasn't implemented on vanilla. So you need to iterate the items in your bag with lua.

I tried this on 3.3.5a but since the used api functions is also present on vanilla, it should also work:

    public void UseItemByName(string name, bool lootItem = true)
    {
        if (lootItem)
        {
            Task.Run(async delegate
            {
                robotManager.Helpful.Keyboard.DownKey(wManager.Wow.Memory.WowMemory.Memory.WindowHandle,
                    System.Windows.Forms.Keys.ShiftKey);
                await Task.Delay(2000);
                robotManager.Helpful.Keyboard.UpKey(wManager.Wow.Memory.WowMemory.Memory.WindowHandle,
                    System.Windows.Forms.Keys.ShiftKey);
            });
        }
        wManager.Wow.Helpers.Lua.LuaDoString(
            @"
                            for b=0,4 do
                                for s=1,GetContainerNumSlots(b) do
                                    if (string.find(tostring(GetContainerItemLink(b,s) or """"), """+wManager.Wow.Helpers.ItemsManager.GetIdByName(name)[email protected]""" )) then
                                        UseContainerItem(b,s, onSelf);
                                    end
                                end
                            end
                            "
        );
    }

Usage:

        UseItemByName("Hearthstone", false);

or

        UseItemByName("Heavy Crate", true);

 

Edited by reapler
altered method
Link to comment
Share on other sites

Hey thanks for the help.

I discovered 2 weird problems:
First the lua does not accept the item name "Big-mouth Clam", if you just write "Clam" or "Big" it will work. Seems to be a problem with the "-", but i don't know how to escape it :(
Second the keydown function seems to have no effect. Although if you hold down the shift key manually it works fine and will loot the clams.

edit:
hm weird. tried some things to get the item name with the "-" working but WoW itself seems to have a problem with it's own item name.

Link to comment
Share on other sites

I've changed the keys to press & the string to search. It should work now. The requirements to use it successfully are:

Wow.exe on foreground(it can reset the key on window switch) and the item must be in cache.

Edited by reapler
Link to comment
Share on other sites

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
 Share

×
×
  • Create New...