vb模拟按键
2014-01-23
展开全部
两个command (C1是开始 C2是结束) 一个timer(设成Interval = 200,Enabled =False )不设也可以试试 点开始后点到你要的窗口上去就会动了
Private Declare Sub keybd_event Lib "user32" (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)Private Sub Command1_Click()
Timer1.Enabled = True
End SubPrivate Sub Command2_Click()
Timer1.Enabled = False
End SubPrivate Sub Form_Load()
Timer1.Interval = 200
Timer1.Enabled = False
End SubPrivate Sub Timer1_Timer()
keybd_event 49, 0, 0, 0
keybd_event 49, 0, 2, 0
Sleep 200
keybd_event 50, 0, 0, 0
keybd_event 50, 0, 2, 0
Sleep 200
keybd_event 51, 0, 0, 0
keybd_event 51, 0, 2, 0
End Sub
Private Declare Sub keybd_event Lib "user32" (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)Private Sub Command1_Click()
Timer1.Enabled = True
End SubPrivate Sub Command2_Click()
Timer1.Enabled = False
End SubPrivate Sub Form_Load()
Timer1.Interval = 200
Timer1.Enabled = False
End SubPrivate Sub Timer1_Timer()
keybd_event 49, 0, 0, 0
keybd_event 49, 0, 2, 0
Sleep 200
keybd_event 50, 0, 0, 0
keybd_event 50, 0, 2, 0
Sleep 200
keybd_event 51, 0, 0, 0
keybd_event 51, 0, 2, 0
End Sub
AiPPT
2024-09-19 广告
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图...
点击进入详情页
本回答由AiPPT提供
2014-01-23
展开全部
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = False '1秒按一次
Timer1.Interval = 1 * 1000
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Button1.Text = "开始" Then
Button1.Text = "停止"
Timer1.Enabled = True
Else
Button1.Text = "开始"
Timer1.Enabled = False
End If
End Sub Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
SendKeys.Send("{1}")
SendKeys.Send("{2}")
SendKeys.Send("{3}")
End Sub
Timer1.Enabled = False '1秒按一次
Timer1.Interval = 1 * 1000
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Button1.Text = "开始" Then
Button1.Text = "停止"
Timer1.Enabled = True
Else
Button1.Text = "开始"
Timer1.Enabled = False
End If
End Sub Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
SendKeys.Send("{1}")
SendKeys.Send("{2}")
SendKeys.Send("{3}")
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2014-01-23
展开全部
还是蓝色的那个回答,Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
‘这里换成 SendMessage(你窗口的句柄,WM_KEYDOWN,(LPARAM)'1',null);SendMessage(你窗口的句柄,WM_KEYDOWN,(LPARAM)'2',null);SendMessage(你窗口的句柄,WM_KEYDOWN,(LPARAM)'3',null);'这个是c++的写法,VB语法我不会,但我知道你vb可以用SendMessage函数,你声明一下就可以了
End Sub
‘这里换成 SendMessage(你窗口的句柄,WM_KEYDOWN,(LPARAM)'1',null);SendMessage(你窗口的句柄,WM_KEYDOWN,(LPARAM)'2',null);SendMessage(你窗口的句柄,WM_KEYDOWN,(LPARAM)'3',null);'这个是c++的写法,VB语法我不会,但我知道你vb可以用SendMessage函数,你声明一下就可以了
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询