public static bool ClickOnCube(ActorCommonData inputCubeStand) { bool FoundCube = false; int LoopCounter = 0; // Attempt to click on Cube, wait 2 sec (10x200ms) while (!FoundCube && LoopCounter <= 10) { float RX_Cube, RY_Cube; LoopCounter += 1; // Try to find where the cube is? A_Tools.T_World.ToScreenCoordinate(inputCubeStand.x0D0_WorldPosX, inputCubeStand.x0D4_WorldPosY, inputCubeStand.x0D8_WorldPosZ, out RX_Cube, out RY_Cube); // If vendor page or kanai page is not already visible, click it bool IsVendorPageVisible = Tools.IsVendorPage_Visible(); bool IsKanaiCubeMainPageVisible = Tools.IsKanaisCube_MainPage_Visible(); if (!IsVendorPageVisible) { // Move mouse cursor to the cube location coord and click it A_Tools.InputSimulator.IS_Mouse.MoveCursor((uint)RX_Cube, (uint)RY_Cube); A_Tools.InputSimulator.IS_Mouse.LeftClick(); Thread.Sleep(200); } if (IsVendorPageVisible && IsKanaiCubeMainPageVisible) { FoundCube = true; } } return(FoundCube); }
public static void DoUpgrade() { try { IsUpgrading_Rare = true; ActorCommonData CubeStand; bool CubeNearby = Tools.IsCubeNearby(out CubeStand); if (CubeNearby) { while (true) { float RX_Cube, RY_Cube; A_Tools.T_World.ToScreenCoordinate(CubeStand.x0D0_WorldPosX, CubeStand.x0D4_WorldPosY, CubeStand.x0D8_WorldPosZ, out RX_Cube, out RY_Cube); if (Tools.IsVendorPage_Visible() && Tools.IsKanaisCube_MainPage_Visible()) { break; } A_Tools.InputSimulator.IS_Mouse.MoveCursor((uint)RX_Cube, (uint)RY_Cube); A_Tools.InputSimulator.IS_Mouse.LeftClick(); Thread.Sleep(100); } Stopwatch s1 = new Stopwatch(); ///////// s1.Start(); /////////// var UpgradableItems = Tools.Get_RareUpgradableItems(); List <ActorCommonData> Materials; var Count_AvailableEnchants = Tools.Get_AvailableEnchants_UpgradeRare(out Materials); var Count_Enchants = 0; foreach (var item in UpgradableItems) { if (Count_Enchants == Count_AvailableEnchants) { break; } while (true) { float RX_Cube, RY_Cube; A_Tools.T_World.ToScreenCoordinate(CubeStand.x0D0_WorldPosX, CubeStand.x0D4_WorldPosY, CubeStand.x0D8_WorldPosZ, out RX_Cube, out RY_Cube); if (Tools.IsVendorPage_Visible() && Tools.IsKanaisCube_MainPage_Visible()) { break; } A_Tools.InputSimulator.IS_Mouse.MoveCursor((uint)RX_Cube, (uint)RY_Cube); A_Tools.InputSimulator.IS_Mouse.LeftClick(); Thread.Sleep(100); } UIRect UIRect_item = A_Collection.D3UI.InventoryItemUIRectMesh.FirstOrDefault( x => x.Key.ItemSlotX == item.x118_ItemSlotX && x.Key.ItemSlotY == item.x11C_ItemSlotY) .Value; A_Tools.InputSimulator.IS_Mouse.RightCLick((int)UIRect_item.Left, (int)UIRect_item.Top, (int)UIRect_item.Right, (int)UIRect_item.Bottom); Thread.Sleep(100); foreach (var material in Materials) { UIRect UIRect_material = A_Collection.D3UI.InventoryItemUIRectMesh.FirstOrDefault( x => x.Key.ItemSlotX == material.x118_ItemSlotX && x.Key.ItemSlotY == material.x11C_ItemSlotY) .Value; A_Tools.InputSimulator.IS_Mouse.RightCLick((int)UIRect_material.Left, (int)UIRect_material.Top, (int)UIRect_material.Right, (int)UIRect_material.Bottom); Thread.Sleep(100); } UIRect Transmute = A_Tools.T_D3UI.UIElement.getRect(BTN_Transmute); A_Tools.InputSimulator.IS_Mouse.LeftClick((int)Transmute.Left, (int)Transmute.Top, (int)Transmute.Right, (int)Transmute.Bottom); Thread.Sleep(100); while (Tools.IsVendorPage_Visible()) { A_Tools.InputSimulator.IS_Keyboard.Close_AllWindows(); } Count_Enchants++; } s1.Stop(); ///////// TimeSpan t1 = s1.Elapsed; ////// Console.WriteLine(t1.TotalSeconds); //////// } IsUpgrading_Rare = false; } catch (Exception) { IsUpgrading_Rare = false; } }
public static void DoConvert(string FromMaterialQuality, string ToMaterialQuality) { // check input if ((FromMaterialQuality == "normal" || FromMaterialQuality == "magic" || FromMaterialQuality == "rare") && (ToMaterialQuality == "normal" || ToMaterialQuality == "magic" || ToMaterialQuality == "rare")) { try { IsConvertingMaterial = true; ActorCommonData CubeStand; bool CubeNearby = Tools.IsCubeNearby(out CubeStand); if (CubeNearby) { if (Tools.ClickOnCube(CubeStand)) { Stopwatch s1 = new Stopwatch(); ///////// s1.Start(); /////////// // Get list of Materials to convert from List <ActorCommonData> Materials; var Count_AvailableEnchants = Tools.Get_AvailableMaterial_Convert(FromMaterialQuality, out Materials); // Get list of equipment of the specified quality var ToItemList = Tools.Get_Items(ToMaterialQuality); var Count_Enchants = 0; foreach (var item in ToItemList) { if (Count_Enchants == Count_AvailableEnchants) { break; } if (Tools.ClickOnCube(CubeStand)) { // Find the item position and rightclick on the item UIRect UIRect_item = A_Collection.D3UI.InventoryItemUIRectMesh.FirstOrDefault(x => x.Key.ItemSlotX == item.x118_ItemSlotX && x.Key.ItemSlotY == item.x11C_ItemSlotY).Value; A_Tools.InputSimulator.IS_Mouse.RightCLick((int)UIRect_item.Left, (int)UIRect_item.Top, (int)UIRect_item.Right, (int)UIRect_item.Bottom); Thread.Sleep(200); // Find the positions and rightclick on materials (RP/AD/VC) foreach (var material in Materials) { UIRect UIRect_material = A_Collection.D3UI.InventoryItemUIRectMesh.FirstOrDefault( x => x.Key.ItemSlotX == material.x118_ItemSlotX && x.Key.ItemSlotY == material.x11C_ItemSlotY).Value; A_Tools.InputSimulator.IS_Mouse.RightCLick((int)UIRect_material.Left, (int)UIRect_material.Top, (int)UIRect_material.Right, (int)UIRect_material.Bottom); Thread.Sleep(100); } // Click the Transmute button UIRect Transmute = A_Tools.T_D3UI.UIElement.getRect(BTN_Transmute); A_Tools.InputSimulator.IS_Mouse.LeftClick((int)Transmute.Left, (int)Transmute.Top, (int)Transmute.Right - 10, (int)Transmute.Bottom); Thread.Sleep(500); // Close Cube window after transmute while (Tools.IsVendorPage_Visible()) { A_Tools.InputSimulator.IS_Keyboard.Close_AllWindows(); Thread.Sleep(250); } Count_Enchants++; } } s1.Stop(); ///////// TimeSpan t1 = s1.Elapsed; ////// Console.WriteLine(t1.TotalSeconds); //////// } } IsConvertingMaterial = false; } catch (Exception) { IsConvertingMaterial = false; } } }
public static void DoUpgrade() { try { IsUpgrading_Rare = true; ActorCommonData CubeStand; bool CubeNearby = Tools.IsCubeNearby(out CubeStand); if (CubeNearby) { if (Tools.ClickOnCube(CubeStand)) { Stopwatch s1 = new Stopwatch(); ///////// s1.Start(); /////////// var UpgradableItems = Tools.Get_Items("rare"); var Count_AvailableEnchants = 50; var Count_Enchants = 0; foreach (var item in UpgradableItems) { if (Count_Enchants == Count_AvailableEnchants) { break; } if (Tools.ClickOnCube(CubeStand)) { //receipe button A_Tools.T_D3UI.UIElement.leftClick(UIElements.Kanai_Cube_Recipe_Button); //press next button 2x for upgrade rare menu A_Tools.T_D3UI.UIElement.leftClick(UIElements.Kanai_Cube_Page_Next); A_Tools.T_D3UI.UIElement.leftClick(UIElements.Kanai_Cube_Page_Next); //put item in cube UIRect UIRect_item = A_Collection.D3UI.InventoryItemUIRectMesh.FirstOrDefault( x => x.Key.ItemSlotX == item.x118_ItemSlotX && x.Key.ItemSlotY == item.x11C_ItemSlotY).Value; A_Tools.T_D3UI.UIElement.rightClick(UIRect_item); //fill A_Tools.T_D3UI.UIElement.leftClick(UIElements.Kanai_Cube_Fill_Button); //transmute A_Tools.T_D3UI.UIElement.leftClick(UIElements.Kanai_Cube_Transmute_Button); //close all windows int close_timeout = 2; while (Tools.IsVendorPage_Visible()) { //A_Tools.InputSimulator.IS_Keyboard.Close_AllWindows(); //doesnt work if not assigned :D //Press "X" - Button in Kanais Cube A_Tools.T_D3UI.UIElement.leftClick(UIElements.Kanai_Cube_Exit_Button); close_timeout--; if (close_timeout == 0) { break; } } Count_Enchants++; } } s1.Stop(); ///////// TimeSpan t1 = s1.Elapsed; ////// Console.WriteLine(t1.TotalSeconds); //////// } } IsUpgrading_Rare = false; } catch (Exception) { IsUpgrading_Rare = false; } }