EzPlugins

CloseDialogPlugin

Jul 27th, 2025 (edited)
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.77 KB | None | 0 0
  1. using Turbo.Plugins.Default;
  2. using System;
  3. using System.Windows.Forms;
  4. using System.Runtime.InteropServices;
  5.  
  6. namespace Turbo.Plugins.Ez
  7. {
  8.     public class CloseDialogPlugin : BasePlugin, IAfterCollectHandler
  9.     {
  10.         public static IntPtr D3Hwnd = IntPtr.Zero;
  11.  
  12.         [DllImport("USER32.DLL")]
  13.         private static extern IntPtr FindWindow(string ClassName, string WindowText);
  14.  
  15.         [DllImport("USER32.DLL")]
  16.         private static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
  17.  
  18.         protected IUiElement GreaterRifts_VictoryScreen;
  19.         protected IUiElement GreaterRifts_VictoryScreen_Exit;
  20.  
  21.         protected IUiElement ConversationMain;
  22.         protected IUiElement BountyRewardMain;
  23.         protected IUiElement QuestrewardMain;
  24.  
  25.         protected IUiElement ChatUI;
  26.         protected IUiElement uiSkilllist;
  27.         protected IUiElement uiProfile;
  28.         protected IUiElement uiLeaderboard;
  29.         protected IUiElement uiAchievements;
  30.         protected IUiElement uiGamemenu;
  31.         protected IUiElement uiGuild;
  32.         protected IUiElement uiStore;
  33.  
  34.         protected IUiElement lore_player_dlg;
  35.         protected IUiElement lore_player_close;
  36.         protected IUiElement lore_notify_dlg;
  37.  
  38.         protected IUiElement follower_swap;
  39.         protected IUiElement follower_swap_ButtonOk;
  40.  
  41.         private const long intervalAction = 150;
  42.  
  43.         private long msLapseAction { get; set; } = 0;
  44.  
  45.         public Keys keyCloseDialog { get; set; }
  46.  
  47.         private static IntPtr MakeLParam(int x, int y)
  48.         {
  49.             return (IntPtr)(y << 16 | (x & 65535));
  50.         }
  51.  
  52.         public static void SendPressKey(Keys key)
  53.         {
  54.             SendMessage(D3Hwnd, 256U, (IntPtr)((int)key), IntPtr.Zero);
  55.             SendMessage(D3Hwnd, 257U, (IntPtr)((int)key), IntPtr.Zero);
  56.         }
  57.  
  58.         public void mouseLClickUiE(IUiElement uie)
  59.         {
  60.             IntPtr lParam = MakeLParam((int) (uie.Rectangle.X + uie.Rectangle.Width/2.0f), (int) (uie.Rectangle.Y + uie.Rectangle.Height/2.0f));
  61.             SendMessage(D3Hwnd, 513U, (IntPtr)1, lParam);
  62.             SendMessage(D3Hwnd, 514U, (IntPtr)1, lParam);
  63.         }
  64.  
  65.         public CloseDialogPlugin()
  66.         {
  67.             Enabled = true;
  68.         }
  69.         public override void Load(IController hud)
  70.         {
  71.             base.Load(hud);
  72.  
  73.             keyCloseDialog = Keys.Space; // Close
  74.  
  75.             GreaterRifts_VictoryScreen = Hud.Render.RegisterUiElement("Root.NormalLayer.GreaterRifts_VictoryScreen.LayoutRoot", null, null);
  76.             GreaterRifts_VictoryScreen_Exit = Hud.Render.RegisterUiElement("Root.NormalLayer.GreaterRifts_VictoryScreen.LayoutRoot.Primary_Frame.button_exit", null, null);
  77.  
  78.             ConversationMain = Hud.Render.RegisterUiElement("Root.NormalLayer.conversation_dialog_main", null, null);
  79.             BountyRewardMain = Hud.Render.RegisterUiElement("Root.NormalLayer.BountyReward_main", null, null);
  80.             QuestrewardMain = Hud.Render.RegisterUiElement("Root.NormalLayer.questreward_dialog", null, null);
  81.  
  82.             ChatUI = Hud.Render.RegisterUiElement("Root.NormalLayer.chatentry_dialog_backgroundScreen.chatentry_content.chat_editline", null, null);
  83.             uiSkilllist = Hud.Render.RegisterUiElement("Root.NormalLayer.SkillPane_main.LayoutRoot.SkillsList", null, null);
  84.             uiProfile = Hud.Render.RegisterUiElement("Root.NormalLayer.BattleNetProfile_main.LayoutRoot.OverlayContainer", null, null);
  85.             uiLeaderboard = Hud.Render.RegisterUiElement("Root.NormalLayer.BattleNetLeaderboard_main.LayoutRoot.OverlayContainer", null, null);
  86.             uiAchievements = Hud.Render.RegisterUiElement("Root.NormalLayer.BattleNetAchievements_main.LayoutRoot.OverlayContainer", null, null);
  87.             uiGamemenu = Hud.Render.RegisterUiElement("Root.NormalLayer.gamemenu_dialog.gamemenu_bkgrnd.button_resumeGame", null, null);
  88.             uiGuild = Hud.Render.RegisterUiElement("Root.NormalLayer.Guild_main.LayoutRoot.OverlayContainer", null, null);
  89.             uiStore = Hud.Render.RegisterUiElement("Root.NormalLayer.BattleNetStore_main.LayoutRoot.OverlayContainer", null, null);
  90.  
  91.             lore_player_dlg = Hud.Render.RegisterUiElement("Root.NormalLayer.lore_player_dlg", null, null);
  92.             lore_player_close = Hud.Render.RegisterUiElement("Root.NormalLayer.lore_player_dlg.button_close", null, null);
  93.             lore_notify_dlg = Hud.Render.RegisterUiElement("Root.NormalLayer.lore_notify_dlg", null, null);
  94.  
  95.             follower_swap = Hud.Render.RegisterUiElement("Root.TopLayer.follower_swap", null, null);
  96.             follower_swap_ButtonOk = Hud.Render.RegisterUiElement("Root.TopLayer.follower_swap.subdlg.button_ok", null, null);
  97.  
  98.             D3Hwnd = FindWindow("D3 Main Window Class", null); // D3Hwnd = FindWindow(null, "Diablo III");
  99.         }
  100.  
  101.         public void AfterCollect()
  102.         {
  103.             if (!Hud.Game.IsInGame) return;
  104.  
  105.             if (Hud.Game.CurrentRealTimeMilliseconds > msLapseAction)
  106.             {
  107.                 msLapseAction = Hud.Game.CurrentRealTimeMilliseconds + intervalAction;
  108.                 if (Hud.Game.Me.AnimationState == AcdAnimationState.Transform) return;
  109.                 if (!Hud.Window.IsForeground || Hud.Game.IsPaused || ChatUI.Visible || Hud.Inventory.InventoryMainUiElement.Visible || Hud.Game.MapMode != MapMode.Minimap) return;
  110.                 if (uiSkilllist.Visible || uiProfile.Visible || uiLeaderboard.Visible || uiAchievements.Visible || uiGamemenu.Visible || uiGuild.Visible || uiStore.Visible) return;
  111.  
  112.                 if (ConversationMain.Visible || BountyRewardMain.Visible || QuestrewardMain.Visible)
  113.                 {
  114.                     SendPressKey(keyCloseDialog);
  115.                 }
  116.                 else if (lore_player_dlg.Visible)
  117.                 {
  118.                     if (lore_player_close.Visible)
  119.                         mouseLClickUiE(lore_player_close);
  120.                 }
  121.                 else if (lore_notify_dlg.Visible)
  122.                 {
  123.                     mouseLClickUiE(lore_notify_dlg);
  124.                 }
  125.                 else if (Hud.Game.IsInTown)
  126.                 {
  127.                     if (follower_swap.Visible)
  128.                     {
  129.                         if (follower_swap_ButtonOk.Visible)
  130.                             mouseLClickUiE(follower_swap_ButtonOk);
  131.                     }
  132.                 }
  133.                 else
  134.                 {
  135.                     if (GreaterRifts_VictoryScreen.Visible)
  136.                     {
  137.                         if ( GreaterRifts_VictoryScreen_Exit.Visible)
  138.                             mouseLClickUiE(GreaterRifts_VictoryScreen_Exit);
  139.                     }
  140.                 }
  141.             }
  142.         }
  143.     }
  144. }
Advertisement
Add Comment
Please, Sign In to add comment