盛大推广员必备工具(按键精灵)
源码:
领取每日经验包.rar
(8.46 KB)
需要用按键精灵进行自动输入的页面:http://tg.
做过推广员的都知道.
模块代码:
Public ct As New Collection
窗体代码:
程序代码:
Private Enum KeyEvent EXTENDEDKEY = &H1 KeyUp = &H2 KeyDown = 0 End Enum ' ' 函数功能:该函数合成一次击键事件。系统可使用这种合成的击键事件来产生WM_KEYUP或WM_KEYDOWN消息, ' 键盘驱动程序的中断处理程序调用keybd_event函数。在Windows NT中该函数己被使用Sendlhput来替代它。 ' ' '参数: ' ' bVk:定义一个虚据拟键码。键码值必须在1~254之间。 ' 'bScan: 定义该键的硬件扫描码? ' 'dwFlags: 定义函数操作的名个方面的一个标志位集?应用程序可使用如下一些预定义常数的组合设置标志位? ' ' KEYEVENTF_EXETENDEDKEY:若指定该值,则扫描码前一个值为OXEO(224)的前缀字节。DEYEVENTF_KEYUP: ' 若指定该值,该键将被释放;若未指定该值,该键交被接下。dwExtralnfo:定义与击键相关的附加的32位值。 ' '返回值: 该函数无返回值? ' ' 备注:尽管keybd_event传递一个与OEM相关的硬件扫描码给系统,但应用程序不能用此扫描码。 '系统在内部将扫描码转换成虚拟键码,并且在传送给应用程序前清除键码的UP/down位。应用程序可以摸拟 'PRINTSCREEN键的按下来获得一个屏幕快照,并把它存放到剪切板中。若要做到这一点, '则要将keybd_event的bVk参数置为VK_SNAPSHOT,bScan参数置为0(用以获得全屏快照)或hScan置为1 '(仅获得活动窗口的快照)。Windows CE:WindowsCE支持dwFlags参数附加的标志位。 '即使用KEYEVENTF_SILENT标志模拟击键,而不产生敲击的声音。Windows CE不支持KEYEVENTF_EXTENDEDKEY标志。 ' Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, _ ByVal bScan As Byte, _ ByVal dwFlags As Long, _ ByVal dwExtraInfo As Long) '函数功能:延时 Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) '函数功能:该函数检取指定虚拟键的状态。该状态指定此键是UP状态,DOWN状态, '还是被触发的(开关每次按下此键时进行切换)。 Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer Private Const VK_F1 = &H70 Dim stopRun As Boolean
程序代码:
Private Sub Key_Event(ByVal bVk As Byte, _ ByVal bScan As Byte, _ ByVal dwFlags As KeyEvent, _ ByVal dwExtraInfo As Long) Call keybd_event(bVk, bscn, dwFlags, dwExtraInfo) End Sub
程序代码:
Private Sub Form_Activate() Call Key_Event(VK_F1, 0, KeyDown, 0) Call Key_Event(VK_F1, 0, KeyUp, 0) Call Runs End Sub
程序代码:
Private Sub Form_Load() stopRun = False 'a-z For i = 65 To 90 ct.Add i, Chr$(i + 32) Next '0-9 For i = 48 To 57 ct.Add i, Chr$(i) Next End Sub
程序代码:
Private Sub Runs() Sleep (100) Dim i As Integer i = 1 While i < Len(Text1.Text) And stopRun = False While Asc(Mid(Text1.Text, i, 1)) <> 13 And stopRun = False Call Key_Event(CInt(ct(Mid(Text1.Text, i, 1))), 0, KeyDown, 0) Sleep (10) Call Key_Event(CInt(ct(Mid(Text1.Text, i, 1))), 0, KeyUp, 0) i = i + 1 Sleep (10) DoEvents Wend If Check1.Value = 1 Then PressTab (4) Else PressTab (2) End If PressEnter Sleep (5000) PressEnter Sleep (3000) i = i + 2 PressTab (28) DoEvents Wend DoEvents Call Runs End Sub
程序代码:
'模拟按Tab键 Private Sub PressTab(ByVal i As Integer) For j = 1 To i Call Key_Event(vbKeyTab, 0, KeyDown, 0) Call Key_Event(vbKeyTab, 0, KeyUp, 0) Sleep (10) Next End Sub
程序代码:
'模拟按Enter键 Private Sub PressEnter() Call Key_Event(vbKeyReturn, 0, KeyDown, 0) Call Key_Event(vbKeyReturn, 0, KeyUp, 0) End Sub
程序代码:
'检测是否按下了F1键 Private Sub Timer1_Timer() If GetKeyState(VK_F1) = 1 Then stopRun = False Else stopRun = True End If End Sub