WEBINAR:
On-Demand
Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame
Mouse Wheel Scrolling
Add the following code to the button that gets the Mouse Wheel scrolling settings:
Private Sub btnGetWheelScroll_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnGetWheelScroll.Click
'Open Registry Key
Dim NewKey As RegistryKey = _
Registry.CurrentUser.OpenSubKey("Control Panel\\Desktop", True)
'Get Value
Dim GetVal As String = _
CType(NewKey.GetValue("WheelScrollLines"), String)
txtMouseWheel.Text = GetVal 'Update Display
If GetVal > 25 Then 'If Bigger Than 25 Lines At A Time
txtMouseWheel.Text = "One Page At A Time"
End If
End Sub
What you did here was to create a Registry object, and with this Registry object, you open the HKEY_CURRENT_USER\Control Panel key. You looked for a setting called WheelScrollLines, which is responsible for this mouse feature, and displayed its value in the txtMouseWheel textbox. If the WheelScrollLines setting is larger than 25, it will display "One Page At A Time".
Add the following to change WheelScrollLines:
Private Sub btnChangeWheelScroll_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnChangeWheelScroll.Click
'Open Registry Key
Dim NewKey As RegistryKey = _
Registry.CurrentUser.OpenSubKey("Control Panel\\Desktop", True)
'Change Scroll Lines Amount
NewKey.SetValue("WheelScrollLines", txtMouseWheel.Text)
End Sub
Here, you open the appropriate registry key again, and set its value to whatever text was entered in txtMouseWheel.
Swapping Mouse Buttons
This setting affects whether or not you are left handed or right handed. Create the following Private variable:
Private MouseButt As Integer 'Which Mouse Button?
In the Left Handed and Right Handed Radio Buttons'CheckedChanged events, add the following:
Private Sub rdLeftButton_CheckedChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles rdLeftButton.CheckedChanged
MouseButt = 1 'Left Handed
End Sub
Private Sub rdRightButton_CheckedChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles rdRightButton.CheckedChanged
MouseButt = 0 'Right Handed
End Sub
A setting of 1 indicates that the user is left handed, and a setting of 0 indicates that the user is right handed. To get the current system setting, add the following to this section's Get Setting button:
Private Sub btnGetMouseButton_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnGetMouseButton.Click
'Open Registry Key
Dim NewKey As RegistryKey = _
Registry.CurrentUser.OpenSubKey("Control Panel\\Mouse", True)
'Get Value
Dim GetVal As String = _
CType(NewKey.GetValue("SwapMouseButtons"), String)
Select Case GetVal
Case "0" 'Right Handed?
rdRightButton.Checked = True 'Update Display
rdLeftButton.Checked = False
Case "1" 'Left Handed?
rdLeftButton.Checked = True
rdRightButton.Checked = False
End Select
End Sub
Here, you looked into the SwapMouseButtons setting, and depending on its value, the appropriate radio button would be checked/unchecked. To change this setting, add the following:
Private Sub btnChangeMouseButton_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnChangeMouseButton.Click
'Open Registry Key
Dim NewKey As RegistryKey = _
Registry.CurrentUser.OpenSubKey("Control Panel\\Mouse", True)
'Change Left Handed/Right Handed
NewKey.SetValue("SwapMouseButtons", MouseButt.ToString())
End Sub
You simply wrote the current selected radiobutton's value to SwapMouseButtons—that's it!
Interestingly, you can change this setting via the use of RunDLL32 and User32.dll. The basic breakdown of the command would be:
Process.Start("rundll32.exe", "user32.dll, SwapMouseButton")
Changing the Double-Click Speed
To get the double-click speed, all you need to do is to interrogate the DoubleClickSpeed setting inside HKEY_CURRENT_USER\Control Panel\Mouse. To change it, you just need to write a value to it.
Private Sub btnGetDoubleClickSpeed_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnGetDoubleClickSpeed.Click
'Open Registry Key
Dim NewKey As RegistryKey = _
Registry.CurrentUser.OpenSubKey("Control Panel\\Mouse", True)
'Get Value
Dim GetVal As String = _
CType(NewKey.GetValue("DoubleClickSpeed"), String)
'Update Appropriate TextBox Display
txtDoubleClickSpeed.Text = GetVal
End Sub
Private Sub btnChangeDoubleClickSpeed_Click(ByVal sender _
As System.Object, _
ByVal e As System.EventArgs) Handles btnChangeDoubleClickSpeed.Click
'Open Registry Key
Dim NewKey As RegistryKey = _
Registry.CurrentUser.OpenSubKey("Control Panel\\Mouse", True)
'Set Double-Click Speed
NewKey.SetValue("DoubleClickSpeed", txtDoubleClickSpeed.Text)
'Max (Fastest) = 200
'Min (Slowest) = 900
End Sub
The value for DoubleClickSpeed can be any value between 200 (fastest) and 900 (slowest).
Applying a Click Lock
This is where these settings get a bit tricky. To turn Click Lock on, you need to modify a Registry setting named UserPreferencesMask inside HKEY_CURRENT_USER\Control Panel\Desktop. The reason why I say it can get a bit tricky is because this setting deals with Binary values. So, to interrogate its value, you need to cast this value's columns appropriately, and to set it, you need to change the appropriate binary column to the correct cast value. Here's how it is done:
Private Sub btnGetClickLock_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnGetClickLock.Click
'Open Registry Key
Dim NewKey As RegistryKey = _
Registry.CurrentUser.OpenSubKey("Control Panel\\Desktop", True)
'Check Type Of Value In UserPreferencesMask
If NewKey.GetValueKind("UserPreferencesMask") = _
RegistryValueKind.Binary Then
'Get Current Value
Dim data As Byte() = _
DirectCast(NewKey.GetValue("UserPreferencesMask"), Byte())
If data(1) = 190 Then 'Click Lock Active?
chkClickLock.Checked = True 'Update Display
Else
chkClickLock.Checked = False
End If
End If
End Sub
'Open Registry Key
Private Sub btnChangeClickLock_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnChangeClickLock.Click
Dim NewKey As RegistryKey = _
Registry.CurrentUser.OpenSubKey("Control Panel\\Desktop", True)
'Check Type Of Value In UserPreferencesMask
If NewKey.GetValueKind("UserPreferencesMask") = _
RegistryValueKind.Binary Then
'Get Current Value
Dim data As Byte() = _
DirectCast(NewKey.GetValue("UserPreferencesMask"), Byte())
data(1) = 190 ' Activate Click Lock
NewKey.SetValue("UserPreferencesMask", data) 'Update Registry
End If
End Sub
Comments
There are no comments yet. Be the first to comment!