首页 > 开发 > 综合 > 正文

VB 从零开始编外挂(四)

2024-07-21 02:20:40
字体:
来源:转载
供稿:网友

添加快捷键
--------------------------------------------------------------------------------------------------------------------------------------------------------
需要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
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表