簡體   English   中英

Internet Explorer 7+附加控件選項卡

[英]Internet Explorer 7+ Addon to control tabs

最初的說明,我不是ac#程序員,但是我已經開發了chrome和firefox的插件/擴展,對於與工作相關的項目,我需要Internet Explorer的第三個擴展。

我正在嘗試從IE中的BHO擴展名訪問Internet Explorer實例。 我一直在使用以下資源:

因此,我已經完成了基本的插件工作,並在窗口加載完成時通過注入JavaScript警報框對其進行測試。

我的插件最終將不得不管理兩個選項卡(一個充當主機,另一個充當從屬), 最后提到鏈接涉及該選項卡,但是它需要瀏覽器使用HWND句柄,而且我不確定如何獲取該選項卡。

看起來它可能位於WebBrowser成員.Parent下,但我不知道我需要.Parent該類以獲取IE句柄。

因此,要獲取任何瀏覽器甚至機器上已經在運行的進程的句柄,都可以在以下位置使用FindWindow方法:

user32.dll中

通過以下方式在班級中包括對它的引用:

    // Find by class name and window name
    [DllImport("user32.dll", SetLastError = true)]
    static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

    // Find window name only
    [DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
    static extern IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName);

您可以在班級內像下面這樣調用它們:

    public FindMyWindow(string classname, string windowName)
    {
        IntPtr hWnd = FindWindow(classname, null);
        // Or do
        hWnd = FindWindowByCaption(IntPtr.Zero, windowName);
    }

您可以使用

間諜++

如果需要,Visual Studio 2010附帶提供了該類來查找類名。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM