VB 从零开始编外挂(四)

时间:2009-02-02 07:33:58  来源:第二电脑网  作者:第二电脑网

  第二电脑网导读:-------------------------------------------------------------------- 需要VB API函数: GetAsyncKeyState ←判断函数调用时指定虚拟键的状态 -------------------------------------------------------------------------------------------------------------------------------------------------------- 相关API声明: GetAsyncKeyState
  正文:vb 从零开始编外挂(四)

添加快捷键
--------------------------------------------------------------------------------------------------------------------------------------------------------
需要VB API函数:
GetAsyncKeyState ←判断函数调用时指定虚拟键的状态
--------------------------------------------------------------------------------------------------------------------------------------------------------
相关API声明:
GetAsyncKeyState

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
Private Function MyHotKey(vKeyCode) As Boolean
--------------------------------------------------------------------------------------------------------------------------------------------------------
需要的控件:Timer(interval不为空)
--------------------------------------------------------------------------------------------------------------------------------------------------------
代码
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
Private Function MyHotKey(vKeyCode) As Boolean
MyHotKey = (GetAsyncKeyState(vKeyCode) < 0)
End Function
'然后在循环中或Timer的Timer事件中检测:
Private Sub Timer1_Timer()
If MyHotKey(vbKeyA) And vbKeyControl Then 'ctrl+A
End '关闭
End If
'其中vbkeyA是键盘″A″的常数,其他键可按F1查得。
End Sub
--------------------------------------------------------------------------------------------------------------------------------------------------------
其它方法:
比如按下"ctrl+A"就退出!
'可以设置Form的KeyPreview属性为True,然后在Form_KeyDown事件中添加代码:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = Asc("A") And Shift = vbCtrlMask Then unload me '如果ctrl+A键被按下就退出
End Sub

VB 从零开始编外挂(四)》由第二电脑网原创提供,转载请注明:http://www.002pc.com/master/College/Language/VB/2009-02-02/8921.html


关键字:

关于《VB 从零开始编外挂(四)》文章的评论

站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td