Getting active tab url from Safari
I am trying to get the active tab url for Safari,开发者_如何转开发 so far I was able to get the url from all prominent browsers (IE, Firefox, Chrome, Opera) through a mix of Win32 API calls or DDE.
The issue with safari is even when I enumerate through the windows and call GetWindowText it's always null.
Any solutions out there? thanks!
public static string getChromeURL() {
uint MAX_PATH=255;
IntPtr hChrome, hAddressBox;
hChrome=GetForegroundWindow();
hAddressBox = FindWindowEx(hChrome, IntPtr.Zero,
"Chrome_AutocompleteEditView", IntPtr.Zero);
StringBuilder sb = new StringBuilder(256);
SendMessage(hAddressBox, WM_GETTEXT, (IntPtr)MAX_PATH, sb);
string s = sb.ToString().Trim(new Char[] { ' ', '\0', '\n' });
return s;
}
精彩评论