修复重复发送问题

This commit is contained in:
2025-08-04 15:53:13 +08:00
parent 2e2f13c35f
commit b7aca76137
2 changed files with 2 additions and 11 deletions
+2 -11
View File
@@ -31,19 +31,10 @@ public class MediaControl {
public const uint APPCOMMAND_MEDIA_STOP = 13;
public static void SendMediaCommand(uint command) {
//
IntPtr desktopWindow = GetDesktopWindow();
// Shell
//
IntPtr shellWindow = GetShellWindow();
//
PostMessage(desktopWindow, WM_APPCOMMAND, IntPtr.Zero, (IntPtr)(command << 16));
PostMessage(shellWindow, WM_APPCOMMAND, IntPtr.Zero, (IntPtr)(command << 16));
//
IntPtr foregroundWindow = GetForegroundWindow();
if (foregroundWindow != IntPtr.Zero) {
PostMessage(foregroundWindow, WM_APPCOMMAND, IntPtr.Zero, (IntPtr)(command << 16));
}
}
}
"@