Results 1 to 20 of 20

Thread: [02/03] Interacting with MS IE URL Bar

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    51

    [02/03] Interacting with MS IE URL Bar

    Hi, i have tryed to look through the forums for the answer to my question but im not to sure what im meant to be looking for.. I have found a link to a tutorial but its in vb6 and the control doesnt work in vb.net 2003.

    Ok so this is what im looking to do, what i want to do is create a form that a user inputs 2 peices of data e.g. First name and Second name then from there they press a button and it gets put into a preset URL e.g. if i want to use google search option i would put in the form my search term Fishing in one box and world in the second box so when the user clicks the continue button it will open up a browser with this
    "http://www.google.co.uk/search?hl=en&q=fishing+world&meta="

    in the url bar

    Can anyone help me or point me in the correct direction.

  2. #2
    Hyperactive Member cameron2's Avatar
    Join Date
    Mar 2008
    Location
    Australia
    Posts
    401

    Re: [02/03] Interacting with MS IE URL Bar

    I'm not quite sure what you are trying to do but if you are trying to have you prpgram access the webrowser and doing stuff with it you might want to take a look at the Findwindow, Findwindowex and Sendmessage API.
    If this post helped you, please click the rate button to say thank you! Remember to mark the thread as resolved too.
    Autoclicker, Hide Taskbar, Sounds on internal speaker, Changing Start Button Text (with code)

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    51

    Re: [02/03] Interacting with MS IE URL Bar

    sorry if i wasnt very clear if you look below i will have a form which will define variable1 and variable2 and when the form is submited a web page will be displayed with the url below and the 2 variable words inserted into the url bar as stated below

    Code:
    http://www.google.co.uk/search?hl=en&q=VARIABLE1+VARIABLE2&meta=
    ]

    So if i had variables of

    variable1=Fishing
    and
    Variable2=World
    in the address bar i would get the following

    Code:
    http://www.google.co.uk/search?hl=en&q=fishing+world&meta=
    do you know what i mean

  4. #4
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Re: [02/03] Interacting with MS IE URL Bar

    Hi Richy, try this:
    Code:
    Imports System.Diagnostics
    
    Public Class Form1
    
        Private Sub Form1_Load(ByVal sender As System.Object, _
          ByVal e As System.EventArgs) Handles MyBase.Load
            Dim newIEProcess As New Process
            Dim ieProcessStartInfo As New ProcessStartInfo
            ieProcessStartInfo.Arguments = _
              "http://www.google.co.uk/search?hl=en&q=" & textbox1.text & _
              "+" & textbox2.text & "world&meta="
            ieProcessStartInfo.FileName = "iexplore.exe"
            newIEProcess.StartInfo = ieProcessStartInfo
            newIEProcess.Start()
        End Sub
    End Class

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  5. #5
    Hyperactive Member cameron2's Avatar
    Join Date
    Mar 2008
    Location
    Australia
    Posts
    401

    Re: [02/03] Interacting with MS IE URL Bar

    Ah yes but this will be tricky,
    I'm not sure if there is an easier way but the way i would do it is use Findwindow to get the webbrowsers handle, then use findwindowex to get the url textbox then use the constant GET_TEXT (i'm not really sure how it goes) to grab the text, then i would insert the variables into the text and then put that text back into the url textbox.
    Now as i said before this is quite complicated and i wouldn't be able to code this and if you don't have knowledge about windows API then i wouldn't suggest doing this.

    There is probably an easier way of doing this but this is all i could think of at the moment.
    If this post helped you, please click the rate button to say thank you! Remember to mark the thread as resolved too.
    Autoclicker, Hide Taskbar, Sounds on internal speaker, Changing Start Button Text (with code)

  6. #6
    Hyperactive Member cameron2's Avatar
    Join Date
    Mar 2008
    Location
    Australia
    Posts
    401

    Re: [02/03] Interacting with MS IE URL Bar

    Alex_read's solution looks good.
    If this post helped you, please click the rate button to say thank you! Remember to mark the thread as resolved too.
    Autoclicker, Hide Taskbar, Sounds on internal speaker, Changing Start Button Text (with code)

  7. #7

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    51

    Re: [02/03] Interacting with MS IE URL Bar

    Thanks but i seem to be getting this error

    An unhandled exception of type 'System.Security.SecurityException' occurred in system.windows.forms.dll

    Additional information: Request failed.

    This is when i compile and click a button to start. I changed your code from on form load to button1_click

  8. #8
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Question Re: [02/03] Interacting with MS IE URL Bar

    Well that's odd - it's not the button that's doing this, that's for sure (and I've just tried it too this end before I wrote that). Ok then, can you look at the note they give on this error here please:
    http://msdn2.microsoft.com/en-us/lib...startinfo.aspx

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  9. #9
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [02/03] Interacting with MS IE URL Bar

    why launch IE when you could just launch the URL itself, which in turn will launch the default browser. What if the user doesnt use IE, but firefox or safari?

    A good quick example of the OS being able to handle this is go to start -> run and type a URL like www.vbforums.com and click ok.

    This will launch your default browser to that URL. The same thing could be applied to process.start

    Code:
    process.start("http://www.vbforums.com")
    change the string to be your google query.

  10. #10

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    51

    Re: [02/03] Interacting with MS IE URL Bar

    Quote Originally Posted by alex_read
    Well that's odd - it's not the button that's doing this, that's for sure (and I've just tried it too this end before I wrote that). Ok then, can you look at the note they give on this error here please:
    http://msdn2.microsoft.com/en-us/lib...startinfo.aspx
    Thanks for this although i couldnt find an answer on there

    and

    Quote Originally Posted by kleinma
    why launch IE when you could just launch the URL itself, which in turn will launch the default browser. What if the user doesnt use IE, but firefox or safari?

    A good quick example of the OS being able to handle this is go to start -> run and type a URL like www.vbforums.com and click ok.

    This will launch your default browser to that URL. The same thing could be applied to process.start

    Code:
    process.start("http://www.vbforums.com")
    change the string to be your google query.
    I did this on a totaly new project with nothing but a command button to start this and it thrown up the same
    Code:
    Imports System
    Public Class Form1
        Inherits System.Windows.Forms.Form
    
    #Region " Windows Form Designer generated code "
    
        Public Sub New()
            MyBase.New()
    
            'This call is required by the Windows Form Designer.
            InitializeComponent()
    
            'Add any initialization after the InitializeComponent() call
    
        End Sub
    
        'Form overrides dispose to clean up the component list.
        Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
            If disposing Then
                If Not (components Is Nothing) Then
                    components.Dispose()
                End If
            End If
            MyBase.Dispose(disposing)
        End Sub
    
        'Required by the Windows Form Designer
        Private components As System.ComponentModel.IContainer
    
        'NOTE: The following procedure is required by the Windows Form Designer
        'It can be modified using the Windows Form Designer.  
        'Do not modify it using the code editor.
        Friend WithEvents Button1 As System.Windows.Forms.Button
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
            Me.Button1 = New System.Windows.Forms.Button
            Me.SuspendLayout()
            '
            'Button1
            '
            Me.Button1.Location = New System.Drawing.Point(88, 72)
            Me.Button1.Name = "Button1"
            Me.Button1.TabIndex = 2
            Me.Button1.Text = "Button1"
            '
            'Form1
            '
            Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
            Me.ClientSize = New System.Drawing.Size(292, 126)
            Me.Controls.Add(Me.Button1)
            Me.Name = "Form1"
            Me.Text = "Form1"
            Me.ResumeLayout(False)
    
        End Sub
    
    #End Region
    
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Process.Start("http://www.vbforums.com")
        End Sub
    
    End Class
    Do you think this an error with how i have set vb.net 2003 up?

  11. #11
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [02/03] Interacting with MS IE URL Bar

    What OS are you running? Also is your account an administrator?

  12. #12

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    51

    Re: [02/03] Interacting with MS IE URL Bar

    xp pro and yes im a admin

  13. #13
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [02/03] Interacting with MS IE URL Bar

    strange that you would get a security exception. They are thrown when your user account/code doesn't have the needed permissions on the system to perform the given action.

    Out of curiosity (only because this is a common cause for security exceptions) are you running this project from your local drive? Or from a network drive that is mapped?

  14. #14

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    51

    Re: [02/03] Interacting with MS IE URL Bar

    Its from a networked drive.. ill give it ago from a local drive

  15. #15

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    51

    Re: [02/03] Interacting with MS IE URL Bar

    AAAh this time it opened a window up but gave me an error. using the code you gave me
    Code:
    An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in system.dll
    
    Additional information: The system cannot find the file specified
    but when i used the code given to me by Alex it opend a window and competed the search term which is gr8 but your thought of not actually opening the window is what iwant.

  16. #16
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [02/03] Interacting with MS IE URL Bar

    you can do it from a network drive, you just need to change some .NET framework settings to give full trust to network drives.

    The process is pretty simple:

    Navigate to the permissions manager app you need by going here:
    Start -> Control Panel -> administrative tools -> Microsoft .NET Framework 1.1 Configuration


    Once in there, click on "Runtime Security Policy" in the left treeview, and then in the right panel, click on "Adjust Zone Security". Click next when the first screen comes up, then in the next screen, click on "Local Intranet", and then adjust the slider to "Full Trust". Click Next, then Finish.

    Now anything from a network mapped drive will run with the same permissions as if it were on the local drive.

  17. #17
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [02/03] Interacting with MS IE URL Bar

    Quote Originally Posted by r1chyb
    AAAh this time it opened a window up but gave me an error. using the code you gave me
    Code:
    An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in system.dll
    
    Additional information: The system cannot find the file specified
    but when i used the code given to me by Alex it opend a window and competed the search term which is gr8 but your thought of not actually opening the window is what iwant.
    Post the code you are using. I will take a look at it.

  18. #18

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    51

    Re: [02/03] Interacting with MS IE URL Bar

    Code:
     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim newIEProcess As New Process
            Dim ieProcessStartInfo As New ProcessStartInfo
            ieProcessStartInfo.Arguments = _
              "http://www.google.co.uk/search?hl=en&q=" & textbox1.text & _
              "+" & textbox2.text & "world&meta="
            ieProcessStartInfo.FileName = "iexplore.exe"
            newIEProcess.StartInfo = ieProcessStartInfo
            newIEProcess.Start()
    
        End Sub
    Thanks for all of your help with this )

  19. #19
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [02/03] Interacting with MS IE URL Bar

    I tested this code and it works just fine

    As a side note, is it your intention to append the word "world" to the end of whatever text is in textbox2? That is how your code (and my code) is doing it now, because I was not sure if that was what you wanted.

    Code:
            Dim URL As String = String.Format("http://www.google.co.uk/search?hl=en&q={0}+{1}world&meta=", _
                                            TextBox1.Text, TextBox2.Text)
            Process.Start(URL)

  20. #20

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    51

    Re: [02/03] Interacting with MS IE URL Bar

    No i just wanted the input from 2 text boxes to be passed to the url for searching.. I dont want to add the word world to the end of it that was just an example. but i think i can figure it our from here.

    Thanks Alot Matt.. I will Rate you and your responses

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