|
-
Apr 23rd, 2008, 02:57 AM
#1
Thread Starter
Member
[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.
-
Apr 23rd, 2008, 03:24 AM
#2
Hyperactive Member
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.
-
Apr 23rd, 2008, 03:43 AM
#3
Thread Starter
Member
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
-
Apr 23rd, 2008, 03:51 AM
#4
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
-
Apr 23rd, 2008, 03:52 AM
#5
Hyperactive Member
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.
-
Apr 23rd, 2008, 03:52 AM
#6
Hyperactive Member
Re: [02/03] Interacting with MS IE URL Bar
Alex_read's solution looks good.
-
Apr 23rd, 2008, 05:08 AM
#7
Thread Starter
Member
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
-
Apr 23rd, 2008, 08:18 AM
#8
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
-
Apr 23rd, 2008, 08:24 AM
#9
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.
-
Apr 23rd, 2008, 10:26 AM
#10
Thread Starter
Member
Re: [02/03] Interacting with MS IE URL Bar
 Originally Posted by alex_read
Thanks for this although i couldnt find an answer on there
and
 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?
-
Apr 23rd, 2008, 10:40 AM
#11
Re: [02/03] Interacting with MS IE URL Bar
What OS are you running? Also is your account an administrator?
-
Apr 23rd, 2008, 10:43 AM
#12
Thread Starter
Member
Re: [02/03] Interacting with MS IE URL Bar
xp pro and yes im a admin
-
Apr 23rd, 2008, 10:48 AM
#13
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?
-
Apr 23rd, 2008, 11:03 AM
#14
Thread Starter
Member
Re: [02/03] Interacting with MS IE URL Bar
Its from a networked drive.. ill give it ago from a local drive
-
Apr 23rd, 2008, 11:07 AM
#15
Thread Starter
Member
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.
-
Apr 23rd, 2008, 11:07 AM
#16
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.
-
Apr 23rd, 2008, 11:08 AM
#17
Re: [02/03] Interacting with MS IE URL Bar
 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.
-
Apr 23rd, 2008, 11:13 AM
#18
Thread Starter
Member
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 )
-
Apr 23rd, 2008, 11:30 AM
#19
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)
-
Apr 23rd, 2008, 11:51 AM
#20
Thread Starter
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|