VB.Net WebKitBrowser Enter key issue - vb.net

I'm programming with vb.net 2012 and I'm having an issue with the WebKit.Net framework.
After my webkitbrowser object has loaded a page, I enter in login credentials, now the tab button gets hooked fine but when I hit enter (like people normally do on websites to login rather than actually hitting the login button) it keeps focus on another form object (tab index 0) and hits enter on that, it doesn't hook the enter button to the webkitbrowser.
I have added the following but it hasn't worked.
Private Sub WebKitBrowser2_MouseClick(sender As Object, e As MouseEventArgs) Handles WebKitBrowser2.MouseClick
Me.WebKitBrowser2.Focus()
End Sub
I'm hoping someone has a solution to this issue?

Related

Showing a form in the position where last form was hidden (VB.net)

For a school project, I am developing software that requires the use of multiple forms.
At the moment, when a button is clicked to show a form and hide the current one, it opens in the default location that is set in the properties.
I would like it to know where the last form was hidden, so that it can open the new form in the same location. This is vital as all the forms are the same shape/size and it'll make for a better user experience if the software retains the position that it is moved into.
Thank you for any help! If you have anymore questions, please ask as this is my first time asking a question on here and don't know if I included all relevant information!
Current code for hiding, and showing the form,
This is opening the main form from another form when a button is pressed:
Private Sub btnHome_Click(sender As Object, e As EventArgs) Handles btnHome.Click
Dim Home As Form
Home = frmHome
Me.Hide()
Home.Show()
End Sub
This was fixed by using the line: frmHome.Location = Me.Location and changing the property of the StartPosition (of the form) to Manual
Thanks to this user!
https://stackoverflow.com/users/8967612/41686d6564

How to make an invisible internet explorer?

I have been playing around with VB today and was wondering on the concept of being able to load a webpage in this case radio 1 online player and but having no open browsers visible to the user even though there will be one hidden one in this case this one. Currently I have it set up to simply navigate to the site but was wondering if it was possible to do what was stated above.
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Try
Dim QueryAddress As New StringBuilder()
QueryAddress.Append("http://www.bbc.co.uk/radio/player/bbc_radio_one")
Process.Start(QueryAddress.ToString())
Visible = False
Catch ex As Exception
MessageBox.Show(ex.Message.ToString(), "Unable to station")
End Try
End Sub
If you want to play a radio station you might be better using media player and connecting to the station's radio stream.
Drop windows media player onto your form.
Set its Visible property to False.
add a button with this code inside the button's click event
AxWindowsMediaPlayer1.URL = "http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_med/llnw/bbc_radio_one.m3u8"
And of course your try..catch code as well.
Tada!
I got the url from this website by clicking on the link in the second colum and then right clicking on the data rate that I wanted and copying the linked addres. I then pasted it into the vb.net code that you see

Enable Tab Key in my Web Browser Control

I have a web browser control in a custom task pane control (User Control) and I open it as a sidebar as soon as my Outlook opens (I have created it as an Outlook Addin using Visual Studio 2013). The web browser control has a login form inside it and I would like to place focus on an input control in my web browser control as soon as Outlook opens. I have tried several tricks like placing focus on the custom user control and then placing focus on the input control after the form has loaded but it doesn't place focus on it. Also I have been trying to allow the use of Tab and Delete keys to work inside the web browser control so that I can tab to other controls and play with it like we would do it on a normal browser window. Kindly let me know how I can achieve this as I am out of ideas.
Cheers.
Try to use the Excel WebBrowser Control instead of the System.Windows.Forms WebBrowser; it handles special key forwarding as TAB, DEL, CTRL+V, etc.
For that change the WebBrowser contructor from
new System.Windows.Forms.WebBrowser();
to
new Microsoft.Office.Tools.Excel.Controls.WebBrowser();
You would need to add references to your project:
Project/Add Referernce/Extensions select
Microsoft.Tools.Outlook & Microsoft.Tools.Outlook.v4.0.Utilities
Doc: https://msdn.microsoft.com/en-us/library/microsoft.office.tools.excel.controls.webbrowser.aspx
You can only do that if you install a Windows hook (SetWindowsHookExW(WH_GETMESSAGE, YourHookProc, 0, GetCurrentThreadId()) and in the hook proc detect that messages are supposed to go to your browser, and redirect them accordingly.
It works partially this way but not 100%. First I had to set the TabStop property to True for my webbrowser control and then just set the focus once the document was loaded and that was it. The tab, delete, backspace keys all ran properly.
Private Sub CustomTaskPane_Load(sender As Object, e As EventArgs) Handles Me.Load
TestWebBrowser.Size = New Drawing.Size(Me.Width, Me.Height)
Me.Focus()
TestWebBrowser.Navigate(url)
WaitForPageLoad()
TestWebBrowser.TabIndex = 0
TestWebBrowser.TabStop = True
End Sub
Private Sub TestWebBrowser_DocumentCompleted(sender As Object, e As Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles TestWebBrowser.DocumentCompleted
' Now set the focus on the Web Browser Control
TestWebBrowser.Focus()
End Sub

Visual Basic - URL showing when click on a link

Just wonder if you could help.
Basically I have a little project to finish, I have created a web browser with VB.NET, when I navigate let's say Google.com, I click to open a link on Google's website and it opens in a new page which is fine but the TextBox on my project (where the URL goes) does not appear any URL to which page/website I've gone to.
Can someone help me on this please?
Thank you so much!
Marco
You can do this by adding a handle to the Navigated event of the WebBrowser.
Private Sub WebBrowser1_Navigated(sender As System.Object, e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles WebBrowser1.Navigated
Me.TextBox1.Text = Me.WebBrowser1.Url.ToString()
End Sub
The WebBrowser.Navigated Event is raised when the control has navigated to a new document and has begun loading it.

VB.NET - Webrowser freezes when navigating from Form Load event

I'm trying to load up a YouTube page using Visual Studio 2008 and a very simple Visual Basic project that contains just a WebBrowser. I want to load the page when the form loads:
Private Sub Form1_Load(ByVal sender As Object,
ByVal e As System.EventArgs) Handles Me.Load
WebBrowser1.Navigate("http://code.google.com/apis/youtube/js_example_1.html")
End Sub
Every now & then (occurs once every 3-5 times, but varies), the form just shows a blank white box.
Could someone help me understand why this happens please.
Edit: This 'freeze' happens for any page, such as http://www.google.com. Is my WebBrowser control broken? Only seems to happen when i place the navigate code in the Form Load event, hmmm strange.
This is probably (almost certainly) happening because a form's Load event occurs before its first Paint event, so once in awhile the WebBrowser finishes navigating to Google (or wherever) before the form paints itself the first time, and thus the WebBrowser shows up as just a white box.
A very simple solution to this problem is to just put a Timer control on the form with a short Interval (say, 100 ms), set Enabled to true, and in its Tick event disable the Timer and then call Navigate(...) on your WebBrowser.