Send Key does not fire until double-click - vb.net

The combination of Shift+Ctrl+Plus Sign rotates my PDF in a web browser control. However, I have to click the "Rotate" button 2 times before the document rotates. Why?
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Me.WebBrowser1.Focus()
SendKeys.Send("+(^{+})")
End Sub

SendKeys is an unreliable method for this. I recommend Input Simulator you can even send multiple keys at once.

Related

All Handles disappeared vb.net

I was working on a project and for no reason all Handles disappeared from the form
For example:
Private Sub Button17_Click(sender As Object, e As EventArgs) Handles Button17.Click
has become
Private Sub Button17_Click(sender As Object, e As EventArgs)
I have a lot of tools in the form
Is there a shortcut to retrieve Handles?
This happens if a control is being cut and pasted back on the form or if it's deleted and recreated with the same name.
To recreate the Handles you can click behind the closing bracket and press SPACE - TAB - SPACE and fill the rest up with the help of IntelliSense.
There's nothing to retrieve. They are just regular methods now. You need to attach them to the appropriate events like you would any other method you wrote yourself. Open the Properties window in the designer and click the Events button. Select a control on the form, click the drop-down for the event of interest and select the correct method.

Active X control blocking keyboard events in Visual Basic.net

I have the vlc AxVLCPlugin21 control inside of a visual basic 2010 form and I have set it with the
ability to recognize to pause the video or music whenever I tap the space key.
The code below works and pauses the media when the windows form is showing and the vlc control is
not full screen. However when I make the vlc full screen and tap the space bar the media no longer
pauses. I think the full screen mode causes the windows form keydown event to be blocked.
I am not sure what I could try to fix this. I know the windows form has a previevkeydown event listed below
and the vlc control itself has its own previewkeydown event. But not sure what I might try to get the pause
to work when the space bar is pressed while in full screen mode. Any ideas appreciated. I have often had
problems getting keypresses to work with programs in VB. Is it because different controls seize control depending
on various settings?
I also use a Me.KeyPreview = True in the form load which supposedly forces the windows form to take precedence over taking keystrokes.
One other idea I tried but did not work was using e.Handled = True in the
keydown event which supposedly makes the form take all keyboard events and
will not allow other controls to receive them. Did not work in full screen.
Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.KeyValue = Keys.Space Then
AxVLCPlugin21.playlist.togglePause()
End If
End Sub
Private Sub Form1_PreviewKeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs) Handles MyBase.PreviewKeyDown
End Sub
Private Sub AxVLCPlugin21_PreviewKeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs) Handles AxVLCPlugin21.PreviewKeyDown
End Sub

What would be a proper way to end a .Net app?

I have an app I'm working on and I've given the user a button with the option to close the app at any time - but I'm not sure if this is the best way to go about it so I'm asking for some feedback just to double check.
Here's what I have:
Private Sub CloseButton_Click(ByVal sender As Object, ByVal e As System.Windows.Input.MouseEventArgs) Handles CloseButton.Click
End
End Sub
For all I know this could be a really bad way to achieve this. Please be gentle!
Firstly, you need to close/dispose all the objects you have been instantiating.
Then you can close your application. And to do so, it is better to use Application.Exit Method.
According to MSDN, It should informs all message pumps that they must terminate, and then closes all application windows after the messages have been processed.
Private Sub CloseButton_Click(ByVal sender As Object, ByVal e As System.Windows.Input.MouseEventArgs) Handles CloseButton.Click
Application.Exit
End Sub

close windows form when users click outside

anybody have an idea how to write a code if the user clicks outside windows form, the form will automatically close? I.e., I had two forms, when i show form2 and then i click outside of it, form 2 will closed.
Does this help? Try the first two solutions, one of which should work for you.
Winforms: Close modal dialog when clicking outside the dialog
You can simply utilize the LostFocus built-in event of the Form like this
Private Sub Form1_LostFocus(ByVal sender As Object, ByVal e As EventArgs) _
Handles Me.LostFocus
Me.Close()
End Sub

how to make a simple webapp for sending mail or wall using vb.net

I want to make myself a simple webapp using vb.net.I am trying to make a desktop app by which users can login and send mail or post wall(facebook) with out going into the browser. I have created the forms and all other thing using this tutorial( http://howtostartprogramming.com/vb-net/vb-net-tutorial-41-website-login/ ).This original code is working properly.
I have two problems.
1)I have made some changes of my own to the above code; to click_botton1 i have added this code.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
WebBrowser1.Navigate("http://login.yahoo.com/")
WebBrowser1.Document.GetElementById("login").SetAttribute("value", TextBox1.Text)
WebBrowser1.Document.GetElementById("passwd").SetAttribute("value", TextBox2.Text)
WebBrowser1.Document.GetElementById(".save").InvokeMember("click")
End Sub
but this code is showing error in vb.net(not compiling)
2)After login i want to go straight to the "compose mail page" with out browsing in the web browser window. So i have added this code to the original code.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
WebBrowser1.Document.GetElementById("login").SetAttribute("value", TextBox1.Text)
WebBrowser1.Document.GetElementById("passwd").SetAttribute("value", TextBox2.Text)
WebBrowser1.Document.GetElementById(".save").InvokeMember("click")
'NEWCODE'
webBrowser1.Navigate("http://in.mg50.mail.yahoo.com/neo/launch?.rand=de5jqdp66atmb")
End Sub
but this code is showing error. It will not go to the compose page but will redirect to login page(may be problem with cookies).
how i circumvent this problems
Advance thanks for help
I think a better approach would be to use .Net's System.Web.Mail class.
You will find plenty of resources if you Google it. You will need some simple things like the Yahoo (or other) SMTP server name and the account login info.
This approach will also be immune to changes in the Yahoo mail web page.