有一段时间我试图在常见的VBNET密钥处理程序下捕获Ctrl Alt右移键.
这是我的测试:
这是我的测试:
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右移键?
或者,如何捕获Ctrl Alt右移键组合?
使用标准VB.NET方法无法检测Shifts之间的差异.
您必须为此挂钩Windows API:
原文链接:https://www.f2er.com/vb/255502.html您必须为此挂钩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