Results 1 to 11 of 11

Thread: [RESOLVED] [VB 2010] How to get Internet ExplorerTitle When Visiting a Webpage?

  1. #1

    Thread Starter
    Addicted Member Miklogak's Avatar
    Join Date
    Jan 2013
    Posts
    203

    Resolved [RESOLVED] [VB 2010] How to get Internet ExplorerTitle When Visiting a Webpage?

    Edit: UPS, I've just noticed that I posted in a wrong section... I have requested the topic Moved..



    I have tried using Classnames and Window Handle to get the Titles of Internet Explorere when visiting Webpages, but its simply not allowing me to do so. I have tried using Classname and Win Handle of IE to get the Titles, but I cant make it work.

    I have so far managed to make it work on Chrome and Firefox. But still strugling with IE. My goal is to create a software that Automatically gets the Titles of Active Webrowsers. I have also used the "Microsoft Internet Controls" for the first time to see if I could get the Titles of IE. But I guess thats only allowing me to get a certain info like the Handle and URLs, but not the Title.

    Hope that someone could give me some more advice, or add an example code to get the Webpage Titles of IE.

    Thanks a lot in advance...
    Last edited by Miklogak; Apr 18th, 2014 at 05:00 PM. Reason: Wrong Scction... Have requested the Topic Moved to Visual Basic.NET Forums.

    A huge thanks to all the Great Developers and Helpers on vBForums for helping me and many others! Special thanks to Dunfiddlin, Paul, TechnoGome, , JayInThe813, ident for helping me with my projects througout the years. Incl. those i forgot to mention!

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,930

    Re: [VB 2010] How to get Internet ExplorerTitle When Visiting a Webpage?

    Thread moved from the 'CodeBank VB.Net' forum (which is for you to post working code examples, not questions) to the 'VB.Net' forum... thanks for letting us know

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,481

    Re: [VB 2010] How to get Internet ExplorerTitle When Visiting a Webpage?

    ok here's an example...
    you need a reference to Microsoft.mshtml (.NET) and a reference to Microsoft Internet Controls (COM):

    Code:
    Imports mshtml
    Imports SHDocVw
    
    Public Class Form1
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim shellWindows As SHDocVw.ShellWindows = New SHDocVw.ShellWindows()
            For Each ie As SHDocVw.InternetExplorer In shellWindows
                Dim filename As String = System.IO.Path.GetFileNameWithoutExtension(ie.FullName).ToLower()
                If filename = "iexplore" Then
                    MsgBox(ie.LocationName)
                End If
            Next
        End Sub
    
    End Class

  4. #4
    Fanatic Member
    Join Date
    Oct 2011
    Location
    Sydney, Australia
    Posts
    756

    Re: [VB 2010] How to get Internet ExplorerTitle When Visiting a Webpage?

    OR one could look through the process list

    Code:
      For Each f As Process In Process.GetProcesses
                If f.MainWindowTitle <> "" Then
                    If f.MainWindowTitle.ToString.Contains("Google Chrome") Or f.MainWindowTitle.ToString.Contains("Internet Explorer") Then
                        ListBox1.Items.Add(f.MainWindowTitle)
                    End If
                End If
            Next
    This gets me the below

    Name:  Capture.jpg
Views: 150
Size:  11.2 KB
    My CodeBank Submissions
    • Listbox with transparency and picture support - Click Here
    • Check for a true internet connection - Click Here
    • Open Cash drawer connected to receipt printer - Click Here
    • Custom color and size border around form - Click Here
    • Upload file to website without user logins, includes PHP - Click Here
    • List All Removable USB Storage Devices - Click Here
    • Custom On/Off Slide Control - Click Here
    • Insert multiple rows of data into one database table using parameters - Click Here
    • Trigger USB/Serial Cash Drawer - Click Here

  5. #5

    Thread Starter
    Addicted Member Miklogak's Avatar
    Join Date
    Jan 2013
    Posts
    203

    Re: [VB 2010] How to get Internet ExplorerTitle When Visiting a Webpage?

    @si_the_geek + Rep and thank you very much for the quick response and for accepting my request for moving the thread. You guys are doing an incredible job taking care of a large forum as vBForums...

    @Paul, Thank you so much, Very easy than the code I am using! I tried to add + Rep, But sadly its telling me to spread a few Arround first. About the Code.... I made it work using the exact same method that I had failed with earlier. I had actually missed the option called "LocationName" but had used the other options.. Anyways your Peace of code is less smaller than the one I was using. So again thank you for that...

    @bensonsearch, +Rep ... Awesome method! I am also using a method that seeks for PRocess first. But Sadly my code is 20 times longer.. lol I am grabbing the Handle for each Window + Win Class.. I think I am going for the method you are using for my other Browser Titles! Cheers. And thanks a lot.

    Wish you guys a great Easter BTW,,

    This Thread has been marked Resolved!
    Last edited by Miklogak; Apr 19th, 2014 at 05:51 PM.

    A huge thanks to all the Great Developers and Helpers on vBForums for helping me and many others! Special thanks to Dunfiddlin, Paul, TechnoGome, , JayInThe813, ident for helping me with my projects througout the years. Incl. those i forgot to mention!

  6. #6
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,481

    Re: [VB 2010] How to get Internet ExplorerTitle When Visiting a Webpage?

    My method can be modified to work with all browsers too.

  7. #7

    Thread Starter
    Addicted Member Miklogak's Avatar
    Join Date
    Jan 2013
    Posts
    203

    Re: [VB 2010] How to get Internet ExplorerTitle When Visiting a Webpage?

    @Paul, Sorry yeh I just noticed that you have also added the "Microsoft.mshtml" . While I only had the "Microsoft Internet Controls" and were able to get the Titles of I.E Can you tell me short what is the "mshtml" for and if it is neccesary and if you could add an example of how I can make it work with other Browsers?

    Thank you very much in advance!
    Last edited by Miklogak; Apr 19th, 2014 at 06:29 PM.

    A huge thanks to all the Great Developers and Helpers on vBForums for helping me and many others! Special thanks to Dunfiddlin, Paul, TechnoGome, , JayInThe813, ident for helping me with my projects througout the years. Incl. those i forgot to mention!

  8. #8
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,481

    Re: [RESOLVED] [VB 2010] How to get Internet ExplorerTitle When Visiting a Webpage?

    I think I accidentally left that in the example code. I adapted it from another snippet that was originally written for a different purpose, which I've modified for other uses over time. So I don't think it is necessary in that code, but I'm not at my PC at the moment, so I can't test that.

  9. #9

    Thread Starter
    Addicted Member Miklogak's Avatar
    Join Date
    Jan 2013
    Posts
    203

    Re: [VB 2010] How to get Internet ExplorerTitle When Visiting a Webpage?

    @Paul, Thanks Paul for the quick reply! ou really dont have to, I have many ways I can choose from! I was just wondering how to because I had used many hours but failed. BTW, I will remove the mshtml part thx for letting me know..!

    A huge thanks to all the Great Developers and Helpers on vBForums for helping me and many others! Special thanks to Dunfiddlin, Paul, TechnoGome, , JayInThe813, ident for helping me with my projects througout the years. Incl. those i forgot to mention!

  10. #10
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,481

    Re: [RESOLVED] [VB 2010] How to get Internet ExplorerTitle When Visiting a Webpage?

    just change this:

    Code:
    Dim filename As String = System.IO.Path.GetFileNameWithoutExtension(ie.FullName).ToLower()
    If filename = "iexplore" Then
        MsgBox(ie.LocationName)
    End If
    to this:

    Code:
    MsgBox(ie.LocationName)

  11. #11
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: [RESOLVED] [VB 2010] How to get Internet ExplorerTitle When Visiting a Webpage?

    vb Code:
    1. Public Class Form1
    2.  
    3.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    4.         Dim procs = Process.GetProcesses.Where(Function(p) p.ProcessName = "iexplore" OrElse p.ProcessName = "chrome")
    5.         Me.ListBox1.Items.AddRange(Array.ConvertAll(procs.ToArray, Function(p) p.MainWindowTitle))
    6.     End Sub
    7.  
    8. End Class

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width