1

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

1 回答 1

0

也许将选项卡设置为焦点窗口有效?

[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SetForegroundWindow(IntPtr hWnd);
于 2012-05-10T20:18:36.823 回答