From b120404971fe3847f598a14a2fd700d1b5c01f70 Mon Sep 17 00:00:00 2001 From: Samuel Colburn Date: Fri, 18 Jan 2019 00:29:02 -0500 Subject: [PATCH] Hacky fix to the discord issue Sorting on MainWindowHandle now, but this really only works because the choices for discord are 0 (for voice) and nonzero (for chat). Self-healing ALSO happens to happen in the right order to give us the right handles back, but I don't feel great about this. --- NK2Tray/Properties/AssemblyInfo.cs | 4 ++-- NK2Tray/SessionAndMeta.cs | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/NK2Tray/Properties/AssemblyInfo.cs b/NK2Tray/Properties/AssemblyInfo.cs index 4c4bf81..bc6ac69 100644 --- a/NK2Tray/Properties/AssemblyInfo.cs +++ b/NK2Tray/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.0.9.0")] -[assembly: AssemblyFileVersion("0.0.9.0")] +[assembly: AssemblyVersion("0.0.10.0")] +[assembly: AssemblyFileVersion("0.0.10.0")] diff --git a/NK2Tray/SessionAndMeta.cs b/NK2Tray/SessionAndMeta.cs index e8a4206..5a243ac 100644 --- a/NK2Tray/SessionAndMeta.cs +++ b/NK2Tray/SessionAndMeta.cs @@ -1,6 +1,7 @@ using NAudio.CoreAudioApi; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; namespace NK2Tray @@ -40,12 +41,14 @@ public static List GetSessionMeta(ref SessionCollection sessions foreach (var ident in sessionsByIdent.Keys.ToList()) { Console.WriteLine("Working on " + ident); - var ordered = sessionsByIdent[ident].OrderBy(i => i.GetSessionInstanceIdentifier.Split('|').Last().Split('b').Last()).ToList(); + //var ordered = sessionsByIdent[ident].OrderBy(i => i.GetSessionInstanceIdentifier.Split('|').Last().Split('b').Last()).ToList(); + var ordered = sessionsByIdent[ident].OrderBy(i => (int)Process.GetProcessById((int)i.GetProcessID).MainWindowHandle).ToList(); bool dup = ordered.Count > 1; for (int i = 0; i < ordered.Count; i++) { outSessions.Add(new SessionAndMeta(ordered[i], dup, i)); - Console.WriteLine("" + i + ordered[i].GetSessionInstanceIdentifier); + var process = Process.GetProcessById((int)ordered[i].GetProcessID); + Console.WriteLine("" + i + " - " + ordered[i].GetSessionInstanceIdentifier + " - " + process.MainWindowTitle + " - " + (int)process.MainWindowHandle); } }