From 8fea77c3040c7d32adef0fae8f17a792a5844ffd Mon Sep 17 00:00:00 2001 From: Booker Date: Tue, 2 Jan 2024 19:50:41 +0800 Subject: [PATCH] =?UTF-8?q?:white=5Fcheck=5Fmark:=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=97=B6=E9=92=9F=E6=98=BE=E7=A4=BA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Constant/Constants.cs | 2 +- GeekDesk.csproj | 1 + Plugins/ShowSeconds/SecondsWindow.xaml.cs | 16 +++++++++- Util/WindowUtil.cs | 38 +++++++++++++---------- ViewModel/AppConfig.cs | 20 ++++++++++-- 5 files changed, 56 insertions(+), 21 deletions(-) diff --git a/Constant/Constants.cs b/Constant/Constants.cs index 95e22be..40b117e 100644 --- a/Constant/Constants.cs +++ b/Constant/Constants.cs @@ -9,7 +9,7 @@ namespace GeekDesk.Constant public static string APP_DIR = AppDomain.CurrentDomain.BaseDirectory.Trim(); // 是否为开发模式 - public static bool DEV = false; + public static bool DEV = true; public static string MY_NAME = DEV ? "GeekDesk-D" : "GeekDesk"; diff --git a/GeekDesk.csproj b/GeekDesk.csproj index abd8a5f..7cc64cc 100644 --- a/GeekDesk.csproj +++ b/GeekDesk.csproj @@ -274,6 +274,7 @@ + diff --git a/Plugins/ShowSeconds/SecondsWindow.xaml.cs b/Plugins/ShowSeconds/SecondsWindow.xaml.cs index e1dfd34..6b46e57 100644 --- a/Plugins/ShowSeconds/SecondsWindow.xaml.cs +++ b/Plugins/ShowSeconds/SecondsWindow.xaml.cs @@ -122,9 +122,23 @@ namespace ShowSeconds } } + private void SecondsHookSetFuc(object sender, MouseEventExtArgs e) { - + + IntPtr taskBarWnd = WindowUtil.FindWindow("Shell_TrayWnd", null); + IntPtr tray = WindowUtil.FindWindowEx(taskBarWnd, IntPtr.Zero, "TrayNotifyWnd", null); + //IntPtr trayclock = WindowUtil.FindWindowEx(tray, IntPtr.Zero, "TrayClockWClass", null); + IntPtr trayclock = WindowUtil.GetForegroundWindow(); + StringBuilder title = new StringBuilder(256); + WindowUtil.GetWindowText(trayclock, title, title.Capacity);//得到窗口的标题 + Console.WriteLine(title.ToString()); + if (title.Equals("通知中心")) + { + + } + + if (e.Button == System.Windows.Forms.MouseButtons.Left) { if (ScreenUtil.IsPrimaryFullScreen()) return; diff --git a/Util/WindowUtil.cs b/Util/WindowUtil.cs index 1b91e20..941b39c 100644 --- a/Util/WindowUtil.cs +++ b/Util/WindowUtil.cs @@ -44,29 +44,33 @@ namespace GeekDesk.Util //取得前台窗口句柄函数 [DllImport("user32.dll")] - private static extern IntPtr GetForegroundWindow(); + public static extern IntPtr GetForegroundWindow(); //取得桌面窗口句柄函数 [DllImport("user32.dll")] - private static extern IntPtr GetDesktopWindow(); + public static extern IntPtr GetDesktopWindow(); [DllImport("user32.dll", CharSet = CharSet.Auto)] - private static extern IntPtr FindWindow(string className, string windowName); - [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)] - private static extern IntPtr GetWindow(HandleRef hWnd, int nCmd); - [DllImport("user32.dll")] - private static extern IntPtr SetParent(IntPtr child, IntPtr parent); - [DllImport("user32.dll", EntryPoint = "GetDCEx", CharSet = CharSet.Auto, ExactSpelling = true)] - private static extern IntPtr GetDCEx(IntPtr hWnd, IntPtr hrgnClip, int flags); - [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)] - private static extern bool SetWindowPos(HandleRef hWnd, HandleRef hWndInsertAfter, int x, int y, int cx, int cy, int flags); - [DllImport("user32.dll")] - private static extern int ReleaseDC(IntPtr window, IntPtr handle); - [DllImport("user32.dll")] - static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count); + public static extern IntPtr FindWindow(string className, string windowName); [DllImport("user32.dll")] - private static extern int GetWindowLong(IntPtr hWnd, int nIndex); + public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string className, string windowName); + + [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)] + public static extern IntPtr GetWindow(HandleRef hWnd, int nCmd); [DllImport("user32.dll")] - private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); + public static extern IntPtr SetParent(IntPtr child, IntPtr parent); + [DllImport("user32.dll", EntryPoint = "GetDCEx", CharSet = CharSet.Auto, ExactSpelling = true)] + public static extern IntPtr GetDCEx(IntPtr hWnd, IntPtr hrgnClip, int flags); + [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)] + public static extern bool SetWindowPos(HandleRef hWnd, HandleRef hWndInsertAfter, int x, int y, int cx, int cy, int flags); + [DllImport("user32.dll")] + public static extern int ReleaseDC(IntPtr window, IntPtr handle); + [DllImport("user32.dll")] + public static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count); + + [DllImport("user32.dll")] + public static extern int GetWindowLong(IntPtr hWnd, int nIndex); + [DllImport("user32.dll")] + public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); private const int GWL_STYLE = -16; diff --git a/ViewModel/AppConfig.cs b/ViewModel/AppConfig.cs index 61b62f4..ce40a47 100644 --- a/ViewModel/AppConfig.cs +++ b/ViewModel/AppConfig.cs @@ -105,10 +105,26 @@ namespace GeekDesk.ViewModel private bool? secondsWindow; //秒数窗口 默认打开 - private bool? enableEveryThing; + private bool? enableEveryThing; //开启everything - private bool? alwaysTopmost; + private bool? alwaysTopmost; //是否置顶 + private bool? showIconTitle = true; //是否显示iconTitle + + + public bool? ShowIconTitle + { + get + { + if (showIconTitle == null) showIconTitle = false; + return showIconTitle; + } + set + { + showIconTitle = value; + OnPropertyChanged("ShowIconTitle"); + } + } public bool? AlwaysTopmost {