I have a keyboard hook implementation that changes the output of certain text under given conditions. To determine how to format the output, I need to be able to see which window is in focus, and if Internet Explorer is in focus, I need to be able to determine which URL is open on that specific tab.
I've been working with the code posted by Simon in the following post: Retrieve current URL from C# windows forms application
Process[] localByName = Process.GetProcessesByName("iexplore");
if((Keys)vkCode == Keys.LShiftKey)
{
return CallNextHookEx(_hookID, nCode, wParam, lParam);
}
foreach (Process process in Process.GetProcessesByName("iexplore"))
{
string url = GetInternetExplorerUrl(process);
if (url == null)
continue;
Console.WriteLine("IE Url for '" + process.MainWindowTitle + "' is " + url);
}
As I have Internet Explorer running (and have webpages open for that matter), I was hoping/expecting to see an output of some sort with URLs, showing the URL(s) open. Instead of getting URLs written to the console, I get nothing. In the case where I tried to use GetProcessesByName
, I just get the following output, System.Diagnostics.Process[]