diff --git a/EDMCOverlay/EDMCOverlay/WindowUtils.cs b/EDMCOverlay/EDMCOverlay/WindowUtils.cs new file mode 100644 index 0000000..72581d8 --- /dev/null +++ b/EDMCOverlay/EDMCOverlay/WindowUtils.cs @@ -0,0 +1,49 @@ +using System; +using System.Text; +using System.Runtime.InteropServices; + + +namespace EDMCOverlay +{ + [StructLayout(LayoutKind.Sequential)] + public struct RECT + { + public int Left; + public int Top; + public int Right; + public int Bottom; + } + + + public class WindowUtils + { + public const Int32 WS_EX_LAYERED = 0x00080000; + public const Int32 WS_EX_TRANSPARENT = 0x00000020; + public const Int32 WS_EX_NOACTIVATE = 0x08000000; + + public const int GWL_EXSTYLE = -20; + + public const int DWMWA_TRANSITIONS_FORCEDISABLED = 3; + + [DllImport("dwmapi.dll")] + public static extern UInt32 DwmSetWindowAttribute(IntPtr hWnd, UInt32 attr, ref int value, UInt32 attrLen); + + [DllImport("user32.dll")] + public static extern Int32 SetWindowLong(IntPtr hWnd, int nIndex, Int32 dwNewLong); + + [DllImport("user32.dll", SetLastError = true)] + public static extern Int32 GetWindowLong(IntPtr hWnd, int nIndex); + + [DllImport("user32.dll", SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool GetWindowRect(IntPtr hWnd, ref RECT lpRect); + + + [DllImport("user32.dll")] + public static extern IntPtr GetForegroundWindow(); + + [DllImport("user32.dll")] + public static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count); + } + +} diff --git a/edmcoverlay.py b/edmcoverlay.py index f309f98..6ad9e7a 100644 --- a/edmcoverlay.py +++ b/edmcoverlay.py @@ -136,6 +136,9 @@ def send_raw(self, msg): :param msg: :return: """ + if not self.connnection: + return None + assert isinstance(msg, dict) try: diff --git a/load.py b/load.py index 3af8c40..c16742f 100644 --- a/load.py +++ b/load.py @@ -1,36 +1,18 @@ """ Plugin for EDMCOverlay """ -import time import os from edmcoverlay import ensure_service, Overlay, trace - HERE = os.path.dirname(os.path.abspath(__file__)) PLUGDIR = os.path.dirname(HERE) client = Overlay() -def notify_old_hits(): - """ - If an old copy of HITS is installed, notify the user - :return: - """ - if notify_old_hits.done: - return - notify_old_hits.done = True - hits_overlay_dist = os.path.join(PLUGDIR, "HITS", "EDMCOverlay", "EDMCOverlay.exe") - if os.path.exists(hits_overlay_dist): - client.send_message("warning", - trace("An older version of the HITS plugin is installed, please update it"), - "#ffcc00", 30, 30, ttl=10 - ) -notify_old_hits.done = False - - def plugin_start3(plugin_dir): return plugin_start() + def plugin_start(): """ Start our plugin, add this dir to the search path so others can use our module @@ -39,9 +21,8 @@ def plugin_start(): ensure_service() try: client.send_message("edmcintro", trace("EDMC Ready"), "yellow", 30, 165, ttl=6) - notify_old_hits() - except Exception: - pass + except Exception as err: + print("Error sending message in plugin_start() : {}".format(err)) return "EDMCOverlay"