用keybd_event实现。一直重复按1~2~ 3 ,延时200毫秒
这个怎么实现?有代码最好
用keybd_event实现。一直重复按1~2~ 3 ,延时200毫秒
这个怎么实现?有代码最好
两个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 Sub
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
Private Sub Form_Load()
Timer1.Interval = 200
Timer1.Enabled = False
End Sub
Private 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 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
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