public static List <string> GetTooltip(string slot) { text.Clear(); GInterfaceObject SlotObj = GContext.Main.Interface.GetByName(cSLOT + slot); if (SlotObj != null) { GContext.Main.EnableCursorHook(); SlotObj.Hover(); Thread.Sleep(100); GInterfaceObject ToolTip = GContext.Main.Interface.GetByName("GameTooltip"); if (ToolTip != null) // RecursiveToolTip(ToolTip); { foreach (GInterfaceObject child in ToolTip.Children) { if (child.ToString().Contains("GameTooltipText")) { text.Add(child.LabelText); } } } GContext.Main.DisableCursorHook(); } return(text); }
public static List <string> GetTooltipOnOpenBags(GItem item) { List <string> text = new List <string>(); GInterfaceObject ItemObj = bm.GetItem(item); if (ItemObj != null) { GContext.Main.EnableCursorHook(); ItemObj.Hover(); Thread.Sleep(50); GInterfaceObject ToolTip = GContext.Main.Interface.GetByName("GameTooltip"); if (ToolTip != null) { foreach (GInterfaceObject child in ToolTip.Children) { if (child.ToString().Contains("GameTooltipText")) { text.Add(child.LabelText); } } } GContext.Main.DisableCursorHook(); } return(text); }
public static void Hover(GInterfaceObject u) { if (u != null && u.IsVisible) { GContext.Main.EnableCursorHook(); u.Hover(); GContext.Main.DisableCursorHook(); } }
public static bool Equip(EasyItem E, bool EquipBOE) { PPather.WriteLine(LOG_CATEGORY.INFORMATION, "Equip: Attempting to equip {0}", E.RealName); BagManager bm = new BagManager(); //PPather.WriteLine(String.Format("AutoEquipTask: Equipping {0} (GITem name: {1}", E.RealName, E.GItem.Name)); if (!bm.ClickItem(E.GItem, true)) { PPather.WriteLine(String.Format("Equip: BagManger failed to click item ({0}). Aborting...", E.RealName)); GContext.Main.Debug(String.Format("Equip: BagManger failed to click item ({0}). Aborting...", E.RealName)); return(false); } Thread.Sleep(1000); string BOEButton = "StaticPopup1Button2"; if (EquipBOE) { BOEButton = "StaticPopup1Button1"; } GInterfaceObject AcceptBOE = GContext.Main.Interface.GetByName(BOEButton); if (AcceptBOE != null && AcceptBOE.IsVisible) { GContext.Main.EnableCursorHook(); AcceptBOE.Hover(); AcceptBOE.ClickMouse(false); GContext.Main.DisableCursorHook(); GContext.Main.ClearTarget(); if (EquipBOE) { PPather.WriteLine("Equip: Accepted BOE for " + E.RealName); GContext.Main.Debug("Equip: Accepted BOE for " + E.RealName); bm.CloseAllBags(); bm.UpdateItems(); //Character.SetCurrent(E.Item.Slot, E, true); Character.ReplaceCurrentlyEquipped(E); return(true); } else { PPather.WriteLine("Equip: Declined BOE for " + E.RealName); GContext.Main.Debug("Equip: Declined BOE for " + E.RealName); bm.CloseAllBags(); bm.UpdateItems(); return(false); } } Character.ReplaceCurrentlyEquipped(E); bm.UpdateItems(); bm.CloseAllBags(); return(true); }
//BagNr is 0-4, ItemNr is 1-BagSlots public bool ClickItem(int BagNr, int ItemNr, GItem item, bool RightMouse) { ClickItem: if (tries >= 4) { tries = 1; PPather.WriteLine(LOG_CATEGORY.INFORMATION, "BagManager: Tried to click {0} 3 times now and it didn't work. Aborting :-(", item.Name); return(false); } OpenBag(BagNr); Thread.Sleep(100); //PPather.WriteLine("BagManager: Click item " + BagNr + " " + ItemNr); String itemStr = "ContainerFrame1Item" + ItemNr; GInterfaceObject ItemObj = GContext.Main.Interface.GetByName(itemStr); if (ItemObj != null) { GContext.Main.EnableCursorHook(); ItemObj.Hover(); Thread.Sleep(100); GInterfaceObject ToolTip = GContext.Main.Interface.GetByName("GameTooltip"); if (ToolTip != null) { GInterfaceObject child = ToolTip.Children[0]; // PPather.WriteLine(child.ToString() + " with labeltext " + child.LabelText); if (child.ToString().Contains("GameTooltipTextLeft1")) { if (child.LabelText != item.Name) { PPather.WriteLine(LOG_CATEGORY.INFORMATION, "BagManger: Tried to click item {0} but found {1}. Will try again...", item.Name, child.LabelText); Thread.Sleep(100); GContext.Main.DisableCursorHook(); CloseAllBags(); CurrentOpenBag = -1; // PPather.WriteLine("BagManager: Retry number " + tries); tries++; Thread.Sleep(150); goto ClickItem; } } } GContext.Main.DisableCursorHook(); Functions.Click(ItemObj, RightMouse); return(true); } return(false); }
public override bool DoActivity() { bool AllRanks = false; bool AllTabs = false; int SearchedTab = 0; if ((SpellTab == "Unknown") || (SpellTab == "unknown")) { AllTabs = true; } if ((SpellRank == "Any") || (SpellRank == "any")) { AllRanks = true; } // assigning a bunch of interface objects for later use. SpellBookMicroButton = GContext.Main.Interface.GetByName("SpellbookMicroButton"); SpellbookFrame = GContext.Main.Interface.GetByName("SpellBookFrame"); NextPageButton = GContext.Main.Interface.GetByName("SpellBookNextPageButton"); PrevPageButton = GContext.Main.Interface.GetByName("SpellBookPrevPageButton"); TargetButtonObject = GContext.Main.Interface.GetByName("ActionButton" + TargetButton); if (AllTabs) { SpellTab1 = GContext.Main.Interface.GetByName("SpellBookSkillLineTab1"); SpellTab2 = GContext.Main.Interface.GetByName("SpellBookSkillLineTab2"); SpellTab3 = GContext.Main.Interface.GetByName("SpellBookSkillLineTab3"); SpellTab4 = GContext.Main.Interface.GetByName("SpellBookSkillLineTab4"); } else { SpellTabObject = GContext.Main.Interface.GetByName("SpellBookSkillLineTab" + SpellTab); } // initialize the variables that will later make sure we got the correct spell. bool correctspell = false; bool correctrank = false; // Make sure the spellbook is open before we proceed. if (!SpellbookFrame.IsVisible) { Functions.Click(SpellBookMicroButton, false); } // Here I'm going to populate the list of all 12 Spellbook buttons so I can later iterate through them to find what we are looking for. // I removed this in favor of manually adding everything to an array in the correct order to allow searching through the spell list backwards // List<GInterfaceObject> SpellBookButtonsList = new List<GInterfaceObject>(); //for (int i = 1; i <= 12; i++) //{ // SpellBookButtonsList.Add(GContext.Main.Interface.GetByName("SpellButton" + i.ToString())); //} GInterfaceObject[] SpellBookButtons = new GInterfaceObject[12]; SpellBookButtons[0] = GContext.Main.Interface.GetByName("SpellButton12"); SpellBookButtons[1] = GContext.Main.Interface.GetByName("SpellButton10"); SpellBookButtons[2] = GContext.Main.Interface.GetByName("SpellButton8"); SpellBookButtons[3] = GContext.Main.Interface.GetByName("SpellButton6"); SpellBookButtons[4] = GContext.Main.Interface.GetByName("SpellButton4"); SpellBookButtons[5] = GContext.Main.Interface.GetByName("SpellButton2"); SpellBookButtons[6] = GContext.Main.Interface.GetByName("SpellButton11"); SpellBookButtons[7] = GContext.Main.Interface.GetByName("SpellButton9"); SpellBookButtons[8] = GContext.Main.Interface.GetByName("SpellButton7"); SpellBookButtons[9] = GContext.Main.Interface.GetByName("SpellButton5"); SpellBookButtons[10] = GContext.Main.Interface.GetByName("SpellButton3"); SpellBookButtons[11] = GContext.Main.Interface.GetByName("SpellButton1"); // now copy the whole thing into an array. Thread.Sleep(500); // Making sure that we are on the right spellbook tab if (AllTabs) { Functions.Click(SpellTab1, false); } else { Functions.Click(SpellTabObject, false); } // Now that we're on the right tab, we gotta make sure that we're on the first page too. GotoLastPage(); // Make sure we got the right action bar selected GContext.Main.SendKey("Common.Bar" + TargetBar); // Alright, now it gets interesting. Make sure the spellbook frame is open. if (!SpellbookFrame.IsVisible) { Functions.Click(SpellBookMicroButton, false); } Thread.Sleep(500); SpellSearch: if (!SpellbookFrame.IsVisible) { Functions.Click(SpellBookMicroButton, false); } foreach (GInterfaceObject button in SpellBookButtons) { foreach (GInterfaceObject child in button.Children) { if (child.LabelText == SpellName) { correctspell = true; // found the right spell name } if ((child.LabelText == SpellRank) || AllRanks) { correctrank = true; // found the right spell rank, or all ranks are fine } if (correctrank && correctspell) // only go here if we found a button where both spell name and rank match { Thread.Sleep(500); GContext.Main.EnableCursorHook(); button.BeginDrag(false); Thread.Sleep(250); TargetButtonObject.Hover(); Thread.Sleep(250); TargetButtonObject.EndDrag(false); GContext.Main.DisableCursorHook(); correctrank = false; correctspell = false; if (SpellbookFrame.IsVisible) { Functions.Click(SpellBookMicroButton, false); // close the spellbook if it's open (and it most likely is) } if (GContext.Main.Interface.CursorItemType != GCursorItemTypes.None) { Functions.Click(TargetButtonObject, true); } PPather.WriteLine("Successfully placed " + SpellName + " on action bar " + TargetBar + ", button " + TargetButton + "."); return(true); // we stop here if we found the right button } } correctrank = false; // after checking all children of a button these variables are reset correctspell = false; // this is required for the spell/rank matching to work properly } if (PrevPageButton.IsEnabledInFrame) { if (!SpellbookFrame.IsVisible) { Functions.Click(SpellBookMicroButton, false); } Functions.Click(PrevPageButton, false); goto SpellSearch; // if the previous page button is clickable and we didn't find the right skill yet then go to the previous page and restart the search } if (AllTabs) { SearchedTab++; switch (SearchedTab) { case 1: if (SpellTab2.IsVisible) { Functions.Click(SpellTab2, false); } else { goto PlaceSpellFailed; } Thread.Sleep(200); GotoLastPage(); Thread.Sleep(200); goto SpellSearch; case 2: if (SpellTab3.IsVisible) { Functions.Click(SpellTab3, false); } else { goto PlaceSpellFailed; } Thread.Sleep(200); GotoLastPage(); Thread.Sleep(200); goto SpellSearch; case 3: if (SpellTab4.IsVisible) { Functions.Click(SpellTab4, false); } else { goto PlaceSpellFailed; } Thread.Sleep(200); GotoLastPage(); Thread.Sleep(200); goto SpellSearch; case 4: goto PlaceSpellFailed; } } PlaceSpellFailed: PPather.WriteLine("PlaceSpell was unable to find the specified spell... giving up."); if (SpellbookFrame.IsVisible) { Functions.Click(SpellBookMicroButton, false); // make sure the Spellbook is closed } done = true; return(false); // If we get here then something went wrong :-( }
public static bool Equip(EasyItem E, bool EquipBOE, string slot) { PPather.WriteLine(LOG_CATEGORY.INFORMATION, "Equip: Attempting to equip {0} [{1}]", E.RealName, slot); bool placed = false; BagManager bm = new BagManager(); CharacterFrame.ShowFrame(); GInterfaceObject BagItemObject = null; GInterfaceObject TargetSlotObject; TargetSlotObject = GContext.Main.Interface.GetByName("Character" + slot); //PPather.WriteLine(LOG_CATEGORY.DEBUG, "Equip: TargetSlotObject = {0}", TargetSlotObject.LabelText); GItem[] Items = bm.GetAllItems(); foreach (GItem Item in Items) { if (Item.GUID == E.GUID) { Thread.Sleep(500); BagItemObject = bm.GetItem(Item); //PPather.WriteLine(LOG_CATEGORY.DEBUG, "Equip: BagItemObject = {0}", BagItemObject.LabelText); //PPather.WriteLine("item: " + BagItemObject.ToString()); Functions.Drag(BagItemObject, TargetSlotObject); placed = true; Thread.Sleep(500); string BOEButton = "StaticPopup1Button2"; if (EquipBOE) { BOEButton = "StaticPopup1Button1"; } GInterfaceObject ButtonObject = GContext.Main.Interface.GetByName(BOEButton); if (ButtonObject != null && ButtonObject.IsVisible) { if (!EquipBOE) { placed = false; } GContext.Main.EnableCursorHook(); ButtonObject.Hover(); ButtonObject.ClickMouse(false); GContext.Main.DisableCursorHook(); GContext.Main.ClearTarget(); } } } CharacterFrame.HideFrame(); /* put the old item in bags */ if (GContext.Main.Interface.CursorItemType != GCursorItemTypes.None) { Functions.Click(BagItemObject); } bm.UpdateItems(); bm.CloseAllBags(); if (placed) { Character.ReplaceCurrentlyEquipped(E, slot); return(true); } return(false); }