Klasse browserlocation { public struct URLDetails {
public String URL;
public String Title;
}
public static URLDetails[] InternetExplorer()
{
Process[] pname = Process.GetProcessesByName("iexplore");
if (pname.Length == 0) {
Console.Write("Process is not running ");
}
System.Collections.Generic.List<URLDetails> URLs = new System.Collections.Generic.List<URLDetails>();
var shellWindows = new SHDocVw.ShellWindows();
foreach (SHDocVw.InternetExplorer ie in shellWindows)
URLs.Add(new URLDetails() { URL = ie.LocationURL, Title = ie.LocationName });
return URLs.ToArray();
}
public static string GetChromeUrl(Process process)
{
if (process == null)
throw new ArgumentNullException("process");
if (process.MainWindowHandle == IntPtr.Zero)
return null;
AutomationElement element = AutomationElement.FromHandle(process.MainWindowHandle);
if (element == null)
return null;
AutomationElement edit = element.FindFirst(TreeScope.Subtree, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Edit));
return ((ValuePattern)edit.GetCurrentPattern(ValuePattern.Pattern)).Current.Value as string;
}
}
Klasse Programm
{
static void Main(string[] args)
{
Console.WriteLine("Internet Explorer: ");
(new List<browserlocation.URLDetails>(browserlocation.InternetExplorer())).ForEach(u =>
{
Console.WriteLine("[{0}]\r\n{1}\r\n", u.Title, u.URL);
});
Console.Write("\n press enter to view Chrome current tab URL");
Console.ReadLine();
foreach (Process process in Process.GetProcessesByName("chrome"))
{
string url = browserlocation.GetChromeUrl(process);
if (url == null)
continue;
Console.WriteLine("CH Url for '" + process.MainWindowTitle + "' is " + url);
Console.ReadLine();
}
}
}
'Was ich genau entwickeln möchte: - C# wpf Anwendung verfolgen alle Web-Aktivitäten und dump alle Daten (URL-Name + Zeit + Dauer) in der Datenbank.' Eine Anwendung, die Verkehr abfängt und es dann an ihr Ziel weiterleitet heißt ein Proxy-Server. –
ja, aber ich möchte dies ohne Proxy-Server tun. –
Was Sie beschreiben *** ist *** ein Proxy-Server. Es wäre wahrscheinlich am einfachsten [schreibe wireshark, um die gewünschten Daten zu erfassen und in eine Datenbank zu schreiben] (https://wiki.wireshark.org/Tools#Intrusion_Analysis_.2F_SQL_Database_Support). –