VB 如何识别键盘左右的shift,Ctrl或Alt键_VB.net_黑客防线网安服务器维护基地--Powered by WWW.RONGSEN.COM.CN

VB 如何识别键盘左右的shift,Ctrl或Alt键

作者:黑客防线网安VB教程基地 来源:黑客防线网安VB教程基地 浏览次数:0

本篇关键词:左右键盘如何识别
黑客防线网安网讯:用API (GetAsyncKeyState)实现,在WIN 2K,XP 下有效:Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As IntegerPrivate Const VK_LSHIFT = &HA0Private...

用API (GetAsyncKeyState)实现在WIN 2KXP 下有效:

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Const VK_LSHIFT = &HA0
Private Const VK_RSHIFT = &HA1
Private Const VK_LCTRL = &HA2
Private Const VK_RCTRL = &HA3
Private Const VK_LMENU = &HA4
Private Const VK_RMENU = &H黑客防线

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyShift And Shift = vbShiftMask And (GetAsyncKeyState(VK_LSHIFT) And &H8000) Then MsgBox "you click the Left Shift"
If KeyCode = vbKeyShift And Shift = vbShiftMask And (GetAsyncKeyState(VK_RSHIFT) And &H8000) Then MsgBox "you click the RIGHT Shift"

If KeyCode = vbKeyMenu And Shift = vbAltMask And (GetAsyncKeyState(VK_LMENU) And &H8000) Then MsgBox "you click the Left ALT" ' only ALT was pressed
If KeyCode = vbKeyMenu And Shift = vbAltMask And (GetAsyncKeyState(VK_RMENU) And &H8000) Then MsgBox "you click the RIGHT ALT" ' only ALT was pressed

If KeyCode = vbKeyControl And Shift = vbCtrlMask And (GetAsyncKeyState(VK_LCTRL) And &H8000) Then MsgBox "you click the Left CTRL"
If KeyCode = vbKeyControl And Shift = vbCtrlMask And (GetAsyncKeyState(VK_RCTRL) And &H8000) Then MsgBox "you click the Right CTRL"

End Sub

Private Sub Form_Load()
Me.KeyPreview = True
End Sub

    黑客防线网安服务器维护方案本篇连接:http://www.rongsen.com.cn/show-14681-1.html
网站维护教程更新时间:2012-04-03 01:12:29  【打印此页】  【关闭
我要申请本站N点 | 黑客防线官网 |  
专业服务器维护及网站维护手工安全搭建环境,网站安全加固服务。黑客防线网安服务器维护基地招商进行中!QQ:29769479

footer  footer  footer  footer