VB编程设定一个程序隔1分钟,模拟按下“R“键,然后按下鼠标左键
展开全部
'form里加2个按钮,一个timer
Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Const MOUSEEVENTF_LEFTDOWN = &H2
Const MOUSEEVENTF_LEFTUP = &H4
Private Sub Command1_Click()
Timer1.Enabled = True
Command2.Enabled = True
Command1.Enabled = False
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
Command1.Enabled = True
Command2.Enabled = False
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 1000 '这里改想点多快
Command1.Enabled = True
Command1.Caption = "Start"
Command2.Enabled = False
Command2.Caption = "Stop"
End Sub
Private Sub Timer1_Timer()
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub
Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Const MOUSEEVENTF_LEFTDOWN = &H2
Const MOUSEEVENTF_LEFTUP = &H4
Private Sub Command1_Click()
Timer1.Enabled = True
Command2.Enabled = True
Command1.Enabled = False
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
Command1.Enabled = True
Command2.Enabled = False
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 1000 '这里改想点多快
Command1.Enabled = True
Command1.Caption = "Start"
Command2.Enabled = False
Command2.Caption = "Stop"
End Sub
Private Sub Timer1_Timer()
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2011-09-23
展开全部
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Dim anctlejiang As Long '这句写到通用里
Private Sub Command1_Click()
PostMessage 65674, 100, 17, 0 '这个是按下CTLE键
anctlejiang = 1
Sleep 1000 '延迟1秒
PostMessage 65674, 101, 17, 0 '弹起CTLE键
anctlejiang = 0
End Sub
Private Sub Timer1_Timer()
MsgBox anctlejiang
If anctlejiang <> 0 Then
Dim aa As Long
PostMessage 65674, 201, 1, 0 '这个是按下左键
Label1.Caption = "以按下左键"
aa = anctlejian
If aa <> anctlejian Then
PostMessage 65674, 202, 1, 0 '弹起左键
Label1.Caption = "以弹起左键"
End If
End If
End Sub
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Dim anctlejiang As Long '这句写到通用里
Private Sub Command1_Click()
PostMessage 65674, 100, 17, 0 '这个是按下CTLE键
anctlejiang = 1
Sleep 1000 '延迟1秒
PostMessage 65674, 101, 17, 0 '弹起CTLE键
anctlejiang = 0
End Sub
Private Sub Timer1_Timer()
MsgBox anctlejiang
If anctlejiang <> 0 Then
Dim aa As Long
PostMessage 65674, 201, 1, 0 '这个是按下左键
Label1.Caption = "以按下左键"
aa = anctlejian
If aa <> anctlejian Then
PostMessage 65674, 202, 1, 0 '弹起左键
Label1.Caption = "以弹起左键"
End If
End If
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
就是在按键精灵写的程序,需要一直嗯1 do while true delay 5000
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询