VB编程设定一个程序隔1分钟,模拟按下“R“键,然后按下鼠标左键

 我来答
庚花芳
2011-09-24 · TA获得超过184个赞
知道答主
回答量:487
采纳率:100%
帮助的人:251万
展开全部
'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
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
匿名用户
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

已赞过 已踩过<
你对这个回答的评价是?
评论 收起
nfei6754
2011-09-23 · TA获得超过1128个赞
知道答主
回答量:450
采纳率:0%
帮助的人:289万
展开全部
就是在按键精灵写的程序,需要一直嗯1 do while true delay 5000
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式