private void UpdateStatus(int time = 0) { IntPtr actWin = Utility.GetForegroundWindow(); int calcID; Utility.GetWindowThreadProcessId(actWin, out calcID); bool play_flag = false; this.Dispatcher.BeginInvoke( new Action(() => { Process[] proc = Process.GetProcesses(); foreach (GameExecutionInfo i in items) { if (i.UpdateStatus(proc, calcID, time)) { if (time != 0) { //string date = DateTime.Now.Date.ToString("yyyy-MM-dd"); db.UpdateTimeNow(i.UID, time); } db.UpdateGameTimeInfo(i.UID, i.TotalPlayTime, i.FirstPlayTime, i.LastPlayTime); if (i.Status == ProcStat.Focused) { play_flag = true; PlayMessage.Content = i.Title + " : " + i.TotalPlayTimeString; } break; } } if (!play_flag) { PlayMessage.Content = ""; } OnPropertyChanged("TotalTime"); })); }
private void UpdateStatus(int time = 0) { IntPtr actWin = Utility.GetForegroundWindow(); int calcID; Utility.GetWindowThreadProcessId(actWin, out calcID); var currentProc = Process.GetProcessById(calcID); try { if (System.IO.Path.GetFileName(currentProc.MainModule.FileName) == "main.bin") //SoftDenchi DRM { calcID = Utility.ParentProcessUtilities.GetParentProcess(calcID).Id; } } catch (Exception e) { Console.WriteLine(e); } System.Console.WriteLine(calcID); bool play_flag = false; this.Dispatcher.BeginInvoke( new Action(() => { Process[] proc = Process.GetProcesses(); Dictionary <String, bool> dic = new Dictionary <string, bool>(); foreach (Process p in proc) { try { string path = p.MainModule.FileName.ToLower(); if (dic.ContainsKey(path)) { dic[path] |= p.Id == calcID; } else { dic.Add(p.MainModule.FileName.ToLower(), p.Id == calcID); } } catch (Exception e) { // Console.WriteLine(e); } } string statusBarText = ""; string trayTipText = "Etupirka Version " + FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).FileVersion; foreach (GameExecutionInfo i in items) { bool running = false; if (i.UpdateStatus2(dic, ref running, time)) // if (i.UpdateStatus(proc, calcID,ref running, time)) { if (time != 0) { //string date = DateTime.Now.Date.ToString("yyyy-MM-dd"); db.UpdateTimeNow(i.UID, time); } db.UpdateGameTimeInfo(i.UID, i.TotalPlayTime, i.FirstPlayTime, i.LastPlayTime); if (i.Status == ProcStat.Focused) { play_flag = true; PlayMessage.Content = i.Title + " : " + i.TotalPlayTimeString; if (Properties.Settings.Default.hideListWhenPlaying) { ErogeHelper = true; } } } System.Console.WriteLine(running); if (running) { trayTipText += "\n" + i.Title + " : " + i.TotalPlayTimeString; } } dic.Clear(); if (!play_flag) { PlayMessage.Content = statusBarText; if (Properties.Settings.Default.hideListWhenPlaying) { ErogeHelper = false; } } tbico.ToolTipText = trayTipText; OnPropertyChanged("TotalTime"); })); }