Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Turbo.Plugins.Default;
- using System;
- using System.Windows.Forms;
- using System.Runtime.InteropServices;
- namespace Turbo.Plugins.Ez
- {
- public class CloseDialogPlugin : BasePlugin, IAfterCollectHandler
- {
- public static IntPtr D3Hwnd = IntPtr.Zero;
- [DllImport("USER32.DLL")]
- private static extern IntPtr FindWindow(string ClassName, string WindowText);
- [DllImport("USER32.DLL")]
- private static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
- protected IUiElement GreaterRifts_VictoryScreen;
- protected IUiElement GreaterRifts_VictoryScreen_Exit;
- protected IUiElement ConversationMain;
- protected IUiElement BountyRewardMain;
- protected IUiElement QuestrewardMain;
- protected IUiElement ChatUI;
- protected IUiElement uiSkilllist;
- protected IUiElement uiProfile;
- protected IUiElement uiLeaderboard;
- protected IUiElement uiAchievements;
- protected IUiElement uiGamemenu;
- protected IUiElement uiGuild;
- protected IUiElement uiStore;
- protected IUiElement lore_player_dlg;
- protected IUiElement lore_player_close;
- protected IUiElement lore_notify_dlg;
- protected IUiElement follower_swap;
- protected IUiElement follower_swap_ButtonOk;
- private const long intervalAction = 150;
- private long msLapseAction { get; set; } = 0;
- public Keys keyCloseDialog { get; set; }
- private static IntPtr MakeLParam(int x, int y)
- {
- return (IntPtr)(y << 16 | (x & 65535));
- }
- public static void SendPressKey(Keys key)
- {
- SendMessage(D3Hwnd, 256U, (IntPtr)((int)key), IntPtr.Zero);
- SendMessage(D3Hwnd, 257U, (IntPtr)((int)key), IntPtr.Zero);
- }
- public void mouseLClickUiE(IUiElement uie)
- {
- IntPtr lParam = MakeLParam((int) (uie.Rectangle.X + uie.Rectangle.Width/2.0f), (int) (uie.Rectangle.Y + uie.Rectangle.Height/2.0f));
- SendMessage(D3Hwnd, 513U, (IntPtr)1, lParam);
- SendMessage(D3Hwnd, 514U, (IntPtr)1, lParam);
- }
- public CloseDialogPlugin()
- {
- Enabled = true;
- }
- public override void Load(IController hud)
- {
- base.Load(hud);
- keyCloseDialog = Keys.Space; // Close
- GreaterRifts_VictoryScreen = Hud.Render.RegisterUiElement("Root.NormalLayer.GreaterRifts_VictoryScreen.LayoutRoot", null, null);
- GreaterRifts_VictoryScreen_Exit = Hud.Render.RegisterUiElement("Root.NormalLayer.GreaterRifts_VictoryScreen.LayoutRoot.Primary_Frame.button_exit", null, null);
- ConversationMain = Hud.Render.RegisterUiElement("Root.NormalLayer.conversation_dialog_main", null, null);
- BountyRewardMain = Hud.Render.RegisterUiElement("Root.NormalLayer.BountyReward_main", null, null);
- QuestrewardMain = Hud.Render.RegisterUiElement("Root.NormalLayer.questreward_dialog", null, null);
- ChatUI = Hud.Render.RegisterUiElement("Root.NormalLayer.chatentry_dialog_backgroundScreen.chatentry_content.chat_editline", null, null);
- uiSkilllist = Hud.Render.RegisterUiElement("Root.NormalLayer.SkillPane_main.LayoutRoot.SkillsList", null, null);
- uiProfile = Hud.Render.RegisterUiElement("Root.NormalLayer.BattleNetProfile_main.LayoutRoot.OverlayContainer", null, null);
- uiLeaderboard = Hud.Render.RegisterUiElement("Root.NormalLayer.BattleNetLeaderboard_main.LayoutRoot.OverlayContainer", null, null);
- uiAchievements = Hud.Render.RegisterUiElement("Root.NormalLayer.BattleNetAchievements_main.LayoutRoot.OverlayContainer", null, null);
- uiGamemenu = Hud.Render.RegisterUiElement("Root.NormalLayer.gamemenu_dialog.gamemenu_bkgrnd.button_resumeGame", null, null);
- uiGuild = Hud.Render.RegisterUiElement("Root.NormalLayer.Guild_main.LayoutRoot.OverlayContainer", null, null);
- uiStore = Hud.Render.RegisterUiElement("Root.NormalLayer.BattleNetStore_main.LayoutRoot.OverlayContainer", null, null);
- lore_player_dlg = Hud.Render.RegisterUiElement("Root.NormalLayer.lore_player_dlg", null, null);
- lore_player_close = Hud.Render.RegisterUiElement("Root.NormalLayer.lore_player_dlg.button_close", null, null);
- lore_notify_dlg = Hud.Render.RegisterUiElement("Root.NormalLayer.lore_notify_dlg", null, null);
- follower_swap = Hud.Render.RegisterUiElement("Root.TopLayer.follower_swap", null, null);
- follower_swap_ButtonOk = Hud.Render.RegisterUiElement("Root.TopLayer.follower_swap.subdlg.button_ok", null, null);
- D3Hwnd = FindWindow("D3 Main Window Class", null); // D3Hwnd = FindWindow(null, "Diablo III");
- }
- public void AfterCollect()
- {
- if (!Hud.Game.IsInGame) return;
- if (Hud.Game.CurrentRealTimeMilliseconds > msLapseAction)
- {
- msLapseAction = Hud.Game.CurrentRealTimeMilliseconds + intervalAction;
- if (Hud.Game.Me.AnimationState == AcdAnimationState.Transform) return;
- if (!Hud.Window.IsForeground || Hud.Game.IsPaused || ChatUI.Visible || Hud.Inventory.InventoryMainUiElement.Visible || Hud.Game.MapMode != MapMode.Minimap) return;
- if (uiSkilllist.Visible || uiProfile.Visible || uiLeaderboard.Visible || uiAchievements.Visible || uiGamemenu.Visible || uiGuild.Visible || uiStore.Visible) return;
- if (ConversationMain.Visible || BountyRewardMain.Visible || QuestrewardMain.Visible)
- {
- SendPressKey(keyCloseDialog);
- }
- else if (lore_player_dlg.Visible)
- {
- if (lore_player_close.Visible)
- mouseLClickUiE(lore_player_close);
- }
- else if (lore_notify_dlg.Visible)
- {
- mouseLClickUiE(lore_notify_dlg);
- }
- else if (Hud.Game.IsInTown)
- {
- if (follower_swap.Visible)
- {
- if (follower_swap_ButtonOk.Visible)
- mouseLClickUiE(follower_swap_ButtonOk);
- }
- }
- else
- {
- if (GreaterRifts_VictoryScreen.Visible)
- {
- if ( GreaterRifts_VictoryScreen_Exit.Visible)
- mouseLClickUiE(GreaterRifts_VictoryScreen_Exit);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment