Get input for the Windows (Home) key pressed in VB.NET - vb.net

So far, in my code I have written the following:
Private Sub KeyBox_Keypressed(sender As Object, e As EventArgs) Handles KeyBox.Keypress
If e.Keychar = "key.home" Then
nint_startmenu = True
leftpanel_startmenu.Visible = True
End If
End Sub
But it did not work. Please help me do this.
NOTE: This is open-source and free

Related

how i can solve : cross thread access problem in visual basic coding?

please check the attached picture.
i want to receive data from another application to Visual studio windows form through serial port and apply some conditions to the received data as shown in the picture, but unfortunately i got this error and i tried more to fix it but in vain.
I'm asking your kind help to over ride this problem and edit my code.
Thanks
Private Sub SerialPort1_DataReceived(sender As System.Object, e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
Dim value As Byte = SerialPort1.ReadLine()
If (((value) & 2) <> 0) Then
Label4.Visible = True
End If
End Sub
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
SerialPort1.Open()
End Sub
#Devcon: Don't use Invoke as it leads often to deadlocks, always use BeginInvoke instead (and I would use the methods and properties of the target control and not of the form, but that usually does not matter).
With Label4
If .InvokeRequired Then
.BeginInvoke(Sub() .Visible = True)
Else
.Visible = True
End If
End With
I think you cannot access label4 directly when using Serial Port Reading.
Try replacing Label4.Visible = True with:
if Me.InvokeRequired then
Me.Invoke(Sub() Label4.Visible = True)
else
Label4.Visible = True
end if

How to uncheck other checkboxes by checking a checkbox?

When I press the chkCP1, it unchecks chkYP but chkCP doesn't display its checked state2; I need to double click chkCP before it displays its checked state3.
I used these codes:
Private Sub chkCP_CheckedChanged(sender As Object, e As EventArgs) Handles chkCP.CheckedChanged
chkYP.Checked = False
End Sub
Private Sub chkYP_CheckedChanged(sender As Object, e As EventArgs) Handles chkYP.CheckedChanged
chkCP.Checked = False
End Sub
Figure 1:
Figure 2:
Figure 3:
I would personally use radiobuttons for this as this is what they were intended to do. However, I have seen a time where the option was to select neither option like you can easily do with checkboxes. That being said, You should be able to achieve the desired result by just simply moving your original code into the click event of the checkboxes instead of the checkchanged event. The reason is that when you click one, it triggers the checkchanged event which sets it to false which in turn triggers that controls checkchanged event. Try replacing your original code with
Private Sub chkCP_Click(sender As Object, e As EventArgs) Handles chkCP.Click
chkYP.Checked = False
End Sub
Private Sub chkYP_Click(sender As Object, e As EventArgs) Handles chkYP.Click
chkCP.Checked = False
End Sub
edit:
I tried using if statements and it worked! However, I cannot uncheck the checkbox anymore.
Private Sub chkCP_CheckedChanged(sender As Object, e As EventArgs) Handles chkCP.CheckedChanged
If chkYP.Checked = True Then
chkYP.Checked = False
Else
chkCP.Checked = True
End If
End Sub
Private Sub chkYP_CheckedChanged(sender As Object, e As EventArgs) Handles chkYP.CheckedChanged
If chkCP.Checked = True Then
chkCP.Checked = False
Else
chkYP.Checked = True
End If
End Sub
You might have some issues with recursive event handlers here. If you set chkYP.Checked in chkCP_CheckedChanged, chkYP_CheckedChanged will be triggered. This sets chkCP.Checked, which triggers chkCP_CheckedChanged again.
You might try something like this:
Private _checking As Boolean
Private Sub chkCP_CheckedChanged(sender As Object, e As EventArgs) Handles chkCP.CheckedChanged
If Not _checking Then
_checking = True
chkYP.Checked = False
_checking = False
End If
End Sub
Private Sub chkYP_CheckedChanged(sender As Object, e As EventArgs) Handles chkYP.CheckedChanged
If Not _checking Then
_checking = True
chkCP.Checked = False
_checking = False
End If
End Sub
It may not win a beauty contest, but it might just do the job.
Using Radio Buttons might be a better solution if you want only one of N options selected.
Edit:
Charles May's answer is way more elegant. He handles the Click event instead of the CheckedChanged event. And that also seems to work fine when using the keyboard (pressing the spacebar to toggle the checkbox).

How to do a 'Button.Clicked' tag, but for Bunifu?

I was wondering what the code is to if a button is selected, then say it will send the enter key. This make no sense, I know, and I'm sorry, but my code might help.
Private Sub BunifuCheckbox1_OnChange(sender As Object, e As EventArgs) Handles BunifuCheckbox1.OnChange
If BunifuFlatButton1.clicked() And BunifuCheckbox1.Checked = True Then
SendKeys.Send("{Enter}")
End If
End Sub
So when you look at 'BunifuFlatButton1.clicked' is there a tag for that?
Rather than try to send the string when you change the checkbox, delete that sub and use this. This way, you can change the checkbox and then click the button
Private Sub BunifuFlatButton1_Click(sender As Object, e As EventArgs) Handles BunifuFlatButton1.Click
If BunifuCheckbox1.Checked = True Then
SendKeys.Send("{Enter}")
End If
End Sub

How do I get a "show password" effect in vb.net?

I am making an email login program in visual basic 2015 with various options, one of them being the option to show password or not with probably a check box. It is just a simple, standard windows forms application, I am relatively new to it.
Edit: Answered by jmcilhinney. Thanks! :D
Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
'Display plain text if and only if check box is checked.
TextBox1.UseSystemPasswordChar = Not CheckBox1.Checked
End Sub
Set the UseSystemPasswordChar property of your TextBox to True to mask the password.
Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
'Display plain text if and only if check box is checked.
TextBox1.UseSystemPasswordChar = Not CheckBox1.Checked
End Sub
Private Sub txtPassword_MouseHover(sender As Object, e As EventArgs) Handles txtPassword.MouseHover
txtPassword.PasswordChar = ""
End Sub
Private Sub txtPassword_MouseLeave(sender As Object, e As EventArgs) Handles txtPassword.MouseLeave
txtPassword.PasswordChar = "*"
End Sub
You have to do couple of changes. Change your password textbox UseSystemPasswordChar to false and the PasswordChar to Char(0). Something like this:
If chkViewPassword.Checked Then txbPwd.PasswordChar = Convert.ToChar(0) Else txbPwd.PasswordChar = Convert.ToChar("*")
txbSMTPPwd.UseSystemPasswordChar = Not chkViewPassword.Checked

VLC Player in VB.NET won't seem to detect end of playback, am I doing something wrong?

VLC Player in VB.NET won't seem to detect end of playback, am I doing something wrong?
My intention was to use "_MediaPlayerEndReached" to make the player move onto the next video but instead once playback of a video completes nothing happens, it just stops (as in image below).
Rather than moving onto next video it just stays like this:
FYI: Clips used for testing are free trailers.
Code:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
AxVLCPlugin21.playlist.items.clear()
AxVLCPlugin21.playlist.add("file:///C:/Users/Adminx/Downloads/The_Hobbit_Full_Length_Trailer_2_HD.mp4")
AxVLCPlugin21.playlist.play()
End Sub
Private Sub AxVLCPlugin21_MediaPlayerEndReached(sender As Object, e As EventArgs) Handles AxVLCPlugin21.MediaPlayerEndReached
AxVLCPlugin21.playlist.items.clear()
AxVLCPlugin21.playlist.add("file:///C:/Users/Adminx/Downloads/ShortestVid.avi")
AxVLCPlugin21.playlist.play()
End Sub
End Class
You can't play another media file at the EndReached() event.
The best solution is to create another thread at the end, and this thread will Play the new file, after the REAL end of the media.
Same as MediaPlayer user control.
If you don't know how to create new thread this is the easiest way:
thread = new Thread(() => while(VLC IS PLAYING) {}; PlayNewFile; ));
thread.Start();
I didn't test it, but this should do the work.
The thread is waiting for the VLC to stop the video, and then play the next one.
EDIT:
check this out : DMediaPlayer - Simple VLC frontend
and read in here: .Net_Interface_to_VLC
I've figured out how to do it, using a timer. Thanks for all help
Code:
Public Class Form1
Dim Paused As Boolean = False
Dim Started As Boolean = False
Dim PlayedSecond As Boolean = True
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
PlayedSecond = False
AxVLCPlugin21.playlist.items.clear()
AxVLCPlugin21.playlist.add("file:///C:/Users/Adminx/Downloads/The_Hobbit_Full_Length_Trailer_2_HD.mp4")
AxVLCPlugin21.playlist.play()
Started = True
End Sub
Sub playsecond()
AxVLCPlugin21.playlist.items.clear()
AxVLCPlugin21.playlist.add("file:///C:/Users/Adminx/Downloads/ShortestVid.avi")
AxVLCPlugin21.playlist.play()
PlayedSecond = True
Started = False
End Sub
Private Sub AxVLCPlugin21_pause(sender As Object, e As EventArgs) Handles AxVLCPlugin21.pause
Paused = True
End Sub
Private Sub IsFinished_Tick(sender As Object, e As EventArgs) Handles IsFinished.Tick
If Not AxVLCPlugin21.playlist.isPlaying And Paused = False And Started = True And PlayedSecond = False Then
playsecond()
Started = True
End If
End Sub
Private Sub AxVLCPlugin21_play(sender As Object, e As EventArgs) Handles AxVLCPlugin21.play
Paused = False
End Sub
End Class
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
AxVLCPlugin21.playlist.items.clear()
AxVLCPlugin21.playlist.add("file:///C:/Users/Adminx/Downloads/The_Hobbit_Full_Length_Trailer_2_HD.mp4")
AxVLCPlugin21.playlist.playItem(0)
End Sub
Private Sub AxVLCPlugin21_MediaPlayerEndReached(sender As Object, e As EventArgs) Handles AxVLCPlugin21.MediaPlayerEndReached
AxVLCPlugin21.playlist.items.clear()
AxVLCPlugin21.playlist.add("file:///C:/Users/Adminx/Downloads/ShortestVid.avi")
AxVLCPlugin21.playlist.playItem(0)
End Sub
End Class
you must do so through the new posts. if you do your code, it will reset all doing their first going through the post.
tries okay!
New Seagate