mcloyd Posted February 14, 2014 at 06:14 PM Report #545315 Posted February 14, 2014 at 06:14 PM Boas, Estou com um problema, uma coisa que até parece simples, mas está a ser um berbicacho do caraças... Preciso de extrair o URL de um site para uma variável, mas só estou a conseguir obter parte do mesmo. O URL é do género: http://www.urldomeusite.com/Resources/User_Guide.pdf#IntroductionModule O código que tenho é o seguinte: var openWindowProcesses = System.Diagnostics.Process.GetProcesses().Where(p => p.MainWindowHandle != IntPtr.Zero && p.ProcessName == "iexplore"); foreach (var proc in openWindowProcesses) { Console.WriteLine(proc.ProcessName); Console.WriteLine(proc.MainWindowTitle); } O problema é que não consigo aceder a nenhuma propriedade URL, e no MainWindowTitle apenas obtenho o endereço até ao cardinal:http://www.urldomeusite.com/Resources/User_Guide.pdf Alguma sugestão para ultrapassar este problema?
mcloyd Posted February 20, 2014 at 09:32 AM Author Report #545907 Posted February 20, 2014 at 09:32 AM Problema resolvido. // Will look in iexplore processes for the expected URL. SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindows(); foreach (SHDocVw.InternetExplorer ie in shellWindows) { filename = System.IO.Path.GetFileNameWithoutExtension(ie.FullName).ToLower(); if (filename.Equals("iexplore") && ie.LocationURL.ToLower().Contains(tabToSelect)) { Console.WriteLine("Web Site : {0}", ie.LocationURL); userGuideFound = true; // Closes de IE window. System.Threading.Thread.Sleep(500); ie.Quit(); System.Threading.Thread.Sleep(500); break; } }
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now