VB从零开始编外挂(四)
2006-02-27 21:14:16 来源:WEB开发网核心提示:添加快捷键需要VBAPI函数:GetAsyncKeyState←判断函数调用时指定虚拟键的状态相关API声明:GetAsyncKeyState↓PRivateDeclareFunctionGetAsyncKeyStateLib"user32"(ByValvkeyAsLong)AsIntegerPri
添加快捷键
--------------------------------------------------------------------------------------------------------------------------------------------------------
需要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
->
--------------------------------------------------------------------------------------------------------------------------------------------------------
需要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
->
更多精彩
赞助商链接