IE窗口可以有多个标签。我想使用P / Invoke选择具有匹配标题的选项卡。我已经有代码遍历所有选项卡并检查是否存在此选项卡。
参考P / Inoke:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms633548%28v=vs.85%29.aspx
while ((tabNum++ <= 15) &&
(curChild = FindWindowEx(parentHwnd, curChild, "TabWindowClass", IntPtr.Zero)) != IntPtr.Zero)
{
String sb = GetWindowTitle(curChild);
if (sb.Contains(expectedTitleString))
{
//TODO : I want to select this tab here.
foundTab = true;
break;
}
if (is_ie8)
{
parentHwnd = FindWindowEx(hWnd, parentHwnd, "Frame Tab", IntPtr.Zero);
curChild = IntPtr.Zero;
}
}
答案 0 :(得分:0)
将选项卡设置为聚焦窗口可能有效吗?
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SetForegroundWindow(IntPtr hWnd);