从Safari获取活动标签网址 [英] Getting active tab url from Safari

查看:125
本文介绍了从Safari获取活动标签网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取Safari的活动标签网址,到目前为止,我已经能够通过混合使用Win32 API调用或DDE从所有著名的浏览器(IE,Firefox,Chrome,Opera)获取该网址。

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.

即使我通过Windows枚举并调用GetWindowText时,Safari的问题也总是存在。

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;
}

这篇关于从Safari获取活动标签网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆