如何判断按下的Ctrl键是左边的还是右边的?
4楼和5楼都很好!还有一个问题,如何向指定窗口发送类似与LCtrl+RCtrl+小键盘Enter的消息?满意的话再加50分!...
4楼和5楼都很好!
还有一个问题,如何向指定窗口发送类似与
LCtrl+RCtrl+小键盘Enter
的消息?
满意的话再加50分! 展开
还有一个问题,如何向指定窗口发送类似与
LCtrl+RCtrl+小键盘Enter
的消息?
满意的话再加50分! 展开
5个回答
展开全部
用api来判断...c#的话,也可以调用那个api...
用API (GetAsyncKeyState)实现键盘左右的shift,Ctrl或Alt键的判定,在WIN 2K,XP 下有效:
------------------------------------------------------------
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 = &HA5
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
用API (GetAsyncKeyState)实现键盘左右的shift,Ctrl或Alt键的判定,在WIN 2K,XP 下有效:
------------------------------------------------------------
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 = &HA5
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.wengu.com/main/Article/windows/optimize/performance/200607/30038.shtml
展开全部
左手就是左边的右手也是右边的
娃哈哈阿
娃哈哈阿
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用左手就是左面
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
没办法
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
C#,控件的KeyDown事件
private void txtBarcode_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyCode==Keys.LControlKey)
{
//左ctrl键
}
//Keys.LControlKey; //
//Keys.RControlKey; //右ctrl键
//Keys.LShiftKey; //左shift
//Keys.RShiftKey; //右shift
}
其他的可以通过 Keys枚举类型查找。
private void txtBarcode_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyCode==Keys.LControlKey)
{
//左ctrl键
}
//Keys.LControlKey; //
//Keys.RControlKey; //右ctrl键
//Keys.LShiftKey; //左shift
//Keys.RShiftKey; //右shift
}
其他的可以通过 Keys枚举类型查找。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询