用vb 如何製作自動按鍵 or 鍵盤輸出 作業 ><
按 \" + \" 開始 然後會自動按鍵盤上面的案件 <----------- 如果游標放在可打字的地方會顯現出來
2秒鐘後 按下 a
2秒鐘後 按下b <-------------- a , b重複10次
然後 1秒鐘後 按下 c
30秒鐘後 再按下c
一直循環 直到按下 \" + \" 結束
請各位vb高手解答一下謝謝^^
2006-06-28 13:37:17 · 1 個解答 · 發問者 oOsunboyOo 1 in 電腦與網際網路 ➔ 程式設計
'--以下在表單,表單須置1個Timer--Private Sub Form_Load() Timer1 = False Timer1.Interval = 1000 H = SetWindowsHookEx(0, AddressOf HP, App.hInstance, 0)End SubPrivate Sub Form_Unload(Cancel As Integer) UnhookWindowsHookEx HEnd SubPrivate Sub Timer1_Timer() V = V + 1 Select Case V Case 2 To 40 If V Mod 2 = 0 Then N = IIf(N = 65, 66, 65) keybd_event N, 0, 1, 0 End If Case 41 keybd_event 67, 0, 1, 0 Case 71 keybd_event 67, 0, 1, 0 V = 0 End SelectEnd Sub'--以下在模組--Type Eve M As Long L As Long H As LongEnd TypeDeclare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (D As Any, ByVal S&, ByVal C&)Declare Sub keybd_event Lib "user32.dll" (ByVal V As Byte, ByVal S As Byte, ByVal F&, ByVal D&)Declare Sub UnhookWindowsHookEx Lib "user32" (ByVal H&)Declare Function CallNextHookEx& Lib "user32" (ByVal K&, ByVal N&, ByVal W&, L As Any)Declare Function SetWindowsHookEx& Lib "user32" Alias "SetWindowsHookExA" (ByVal H&, ByVal L&, ByVal M&, ByVal D&)Declare Function MapVirtualKey& Lib "user32" Alias "MapVirtualKeyA" (ByVal wCode As Long, ByVal wMapType As Long)Public H&, V%, N%Function HP&(ByVal C&, ByVal W&, ByVal L&) Dim M As Eve If C = 0 Then CopyMemory M, L, LenB(M) If M.M = &H100 Then If MapVirtualKey(MapVirtualKey(M.H, 1), 2) = 43 Then With Form1.Timer1 .Enabled = Not .Enabled If .Enabled = False Then V = 0: N = 0 End With End If End If End If HP = CallNextHookEx(H, C, W, L)End Function
2006-07-03 10:01:16 · answer #1 · answered by W.J.S. 7 · 0⤊ 0⤋