public static void fncAppTracker() { if (GlobalClass.CheckForInternetConnection()) { try { string title = string.Empty; string appexe = string.Empty; IntPtr handle = GetForegroundWindow(); if (!handle.Equals(IntPtr.Zero)) { int tLength = GetWindowTextLength(handle); if (tLength > 0) { if (tLength > 255) { tLength = 255; } StringBuilder wTitle = new StringBuilder(string.Empty, tLength + 1); if (GetWindowText(handle, wTitle, wTitle.Capacity) > 0) { title = wTitle.ToString(); } if (title != OldTitle && !String.IsNullOrEmpty(title)) { int wProcID = 0; if (GetWindowThreadProcessId(handle, out wProcID) > 0) { appexe = Process.GetProcessById(wProcID).ProcessName; } if (!string.IsNullOrEmpty(appexe)) { if (appexe.Equals("firefox")) { BrowserUrlTracker.ReadBrowserUrlforFirefox(); //BrowserUrlTracker.ReadBrowserUrlforChrome(); } else if (appexe.Equals("iexplore")) { BrowserUrlTracker.ReadBrowserUrlforIE(); } else if (appexe.Equals("chrome")) { BrowserUrlTracker.ReadBrowserUrlforChrome(); } else if (appexe.Equals("opera")) { BrowserUrlTracker.ReadBrowserUrlforOpera(); } else { OldTitle = title; appexe = appexe + ".exe"; WriteData(title, appexe); } } } } } } catch (Exception ex) { Console.WriteLine("Error on AppTracker.cs in fncAppTracker function :- " + ex.Message); GlobalClass.WriteTolog("Error on AppTracker.cs in fncAppTracker function :- " + ex.Message); } } else { GlobalClass.WriteTolog("server not giving any response"); } }