首页 > 学院 > 开发设计 > 正文

VB从零开始编外挂(四)

2019-11-18 17:29:12
字体:
来源:转载
供稿:网友
添加快捷键
--------------------------------------------------------------------------------------------------------------------------------------------------------
需要VBAPI函数:
GetAsyncKeyState←判断函数调用时指定虚拟键的状态
--------------------------------------------------------------------------------------------------------------------------------------------------------
相关API声明:
GetAsyncKeyState

PRivateDeclareFunctionGetAsyncKeyStateLib"user32"(ByValvkeyAsLong)AsInteger
PrivateFunctionMyHotKey(vKeyCode)AsBoolean
--------------------------------------------------------------------------------------------------------------------------------------------------------
需要的控件:Timer(interval不为空)
--------------------------------------------------------------------------------------------------------------------------------------------------------
代码:
PrivateDeclareFunctionGetAsyncKeyStateLib"user32"(ByValvkeyAsLong)AsInteger
PrivateFunctionMyHotKey(vKeyCode)AsBoolean
MyHotKey=(GetAsyncKeyState(vKeyCode)<0)
EndFunction
'然后在循环中或Timer的Timer事件中检测:
PrivateSubTimer1_Timer()
IfMyHotKey(vbKeyA)AndvbKeyControlThen'ctrl A
End'关闭
EndIf
'其中vbkeyA是键盘″A″的常数,其他键可按F1查得。
EndSub
--------------------------------------------------------------------------------------------------------------------------------------------------------
其它方法:
比如按下"ctrl A"就退出!
'可以设置Form的KeyPreview属性为True,然后在Form_KeyDown事件中添加代码:
PrivateSubForm_KeyDown(KeyCodeAsInteger,ShiftAsInteger)
IfKeyCode=Asc("A")AndShift=vbCtrlMaskThenunloadme'如果ctrl A键被按下就退出
EndSub
->


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表