Vb.net 检测换档/上限锁定是否打开

Vb.net 检测换档/上限锁定是否打开,vb.net,Vb.net,可能重复: 我想创建两个与键输入相关的函数: Dim capsLock As Boolean = GetCapsLockState() 'imaginary function Dim shiftKey As Boolean = GetShiftKeyState() 'imaginary function 有人能帮我完成这些功能吗 谢谢如果您使用的是.NET 2.0或更高版本,您可以使用该方法 确实如此。它是在.NET2.0中引入的。它工作得很好:Control.IsKeyLocked(Key

可能重复:

我想创建两个与键输入相关的函数:

Dim capsLock As Boolean = GetCapsLockState() 'imaginary function
Dim shiftKey As Boolean = GetShiftKeyState() 'imaginary function
有人能帮我完成这些功能吗


谢谢

如果您使用的是.NET 2.0或更高版本,您可以使用该方法


确实如此。它是在.NET2.0中引入的。它工作得很好:Control.IsKeyLocked(Keys.CapsLock)。。。如何检测是否按下了shift键?这不起作用:Control.IsKeyLocked(Keys.lsShift键)全部完成。下面是代码:(Control.ModifierKeys和Keys.Shift)=Keys.Shift
Imports System
Imports System.Windows.Forms
Imports Microsoft.VisualBasic

Public Class CapsLockIndicator

    Public Shared Sub Main()
        If Control.IsKeyLocked(Keys.CapsLock) Then
            MessageBox.Show("The Caps Lock key is ON.")
        Else
            MessageBox.Show("The Caps Lock key is OFF.")
        End If
    End Sub 'Main

End Class 'CapsLockIndicator