gpt4 book ai didi

vb.net - 如何捕获 Ctrl + Alt + RShftKey

转载 作者:行者123 更新时间:2023-12-01 16:31:53 26 4
gpt4 key购买 nike

有一段时间,我试图在常见的 VBNET 键处理程序下捕获 Ctrl + Alt + Right Shift Key 。这是我的测试:

    If e.Control And e.Alt And e.KeyCode = Keys.Space Then
MsgBox("CTRL + ALT + SPACE") ' This work
End If

If e.Control And e.Shift And e.KeyCode = Keys.F10 Then
MsgBox("CTRL + SHIFT + F10") ' This work
End If

If e.Control And e.Alt And e.KeyCode = Keys.ShiftKey Then
MsgBox("CTRL + ALT + SHIFT") ' This work
End If

If e.Alt And e.Shift And e.KeyCode = Keys.LWin Then
MsgBox("ALT + SHIFT + LEFT WINDOWS") ' This work
End If

If e.Control And e.Alt And e.KeyCode = Keys.RShiftKey Then
MsgBox("CTRL + ALT + RIGHT SHIFT") ' This don't work
End If

Windows 7、WinForms、VB2008、NET Framework 2.0

为什么在上述情况下我无法捕捉到 Ctrl + Alt + 右 Shift 键
或者,如何捕获 Ctrl + Alt + Right Shift Key 组合?

最佳答案

使用标准 VB.NET 方法无法检测类次之间的差异。为此,您必须连接 Windows API:

 <System.Runtime.InteropServices.DllImport("user32.dll")> _
Private Shared Function GetAsyncKeyState(vKey As Keys) As Short
End Function

Private Sub Form2_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown

If e.Control And e.Alt And e.Shift Then

If Convert.ToBoolean(GetAsyncKeyState(Keys.LShiftKey)) Then
MsgBox("CTRL + ALT + LEFT SHIFT")
ElseIf Convert.ToBoolean(GetAsyncKeyState(Keys.RShiftKey)) Then
MsgBox("CTRL + ALT + RIGHT SHIFT")
End If

End If

End Sub

关于vb.net - 如何捕获 Ctrl + Alt + RShftKey,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18282303/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com