VB定时按键代码,不知道哪里错了,求高手指点

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Interval = 1000
Timer1.Enabled = False
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If Format(Now, "HH:MM:SS") = "16:24:00" Then
SendKeys.Send(keys:=A)
End If
End Sub
End Class

我想在16:24:00时候按A,能运行,但是没按出来,请问代码哪里有问题?谢谢!

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Interval = 1000
Timer1.Enabled = False
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If Format(Now, "HH:MM:SS") = "16:24:00" Then
SendKeys"a"
End If
End Sub
End Class
温馨提示:内容为网友见解,仅供参考
第1个回答  2011-01-17
SendKeys.Send(string:="A")
or
SendKeys.Send("A")

VB定时按键代码,不知道哪里错了,求高手指点
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Timer1.Interval = 1000 Timer1.Enabled = False End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick If Format(Now...

急求高手指点,VB编辑中出现错误,如何在过程中和给定的条件做整体比较...
Private Sub Worksheet_Change(ByVal Target As Range)'MsgBox If Target.Address = "$A$1" Then vl = Cells(Target.Row, Target.Column)xr = Target.Row: xc = Target.Column If Len(vl) = 0 Then Exit Sub ''空值退出 On Error Resume Next x = ActiveSheet.Name 'MsgBox x For Each ...

...缺少语句的错误,实在不知道是哪里写错了,望高手指点!
使用如下代码即可:ActiveWorkbook.Sheets.Add after:=Worksheets(Worksheets.Count)代码解释,after参数的含义是,在某某表的后面插入新表。Worksheets.Count的含义是,所有表的总数;现在,完整的看这行代码:ActiveWorkbook.Sheets.Add after:=Worksheets(Worksheets.Count)其含义是,在当前所有表的总数(也就是...

VB中这段代码是什么意思?请高手指点,求详解。
Do Line Input #1, s '把文件1逐行读入变量s s = Trim(s) '把字符串前后的空格都去掉 If 1 = InStr(1, s,"$number") Then '如果字符串的开头是“$number”s =modifysecond(s, num) '就执行自定义函数modifysecond End If Loop While Not EOF(1) '循环读取文件1的下...

...按钮名称显示为A,再单击显示B,如此在A,B间循环?请各位高手指点...
楼上搞错了好像,应该把事件写在Command的Click()事件里面 Private Sub Command1_Click()If Command1.Caption = "A" Then Command1.Caption = "B"ElseIf Command1.Caption = "B" Then Command1.Caption = "A"Else Command1.Caption = "A"End If End Sub ...

求高手帮忙解决下面这个C++中的一个题目。看俺的代码哪里有错...
你有几个地方有错误:1.求个位数,直接用n%10就可以了,你那样子是求的最高位的值 2.既然你已经定了个位为7,直接给m赋7就可以了吧。3.你上面那样子算的时候,最后退出第一个while循环的时候,n是为0的,下面不能用这个n计算,你若是不断的用n\/=10,开始应该用个变量保存这个n的值 4....

...下拉菜单式怎么弄的?求高手指点迷津!希望从按钮需要修改的按钮内容...
在VB 中加入外部控件 --“日历控件”(工程|部件| 沟上 MicroSoft 日历控件 11.0 应用)再在窗体上划一个 “日历控件”(Calendar1)再写点代码就可以了。以下是我写的一点代码,希望有助于你:Private Sub Text2_GotFocus()Calendar1.Visible = True Calendar1.SetFocus End Sub Privat...

...f,不知道哪里错了,控制cdef的四个键不对,其他都对 求高手指点,多谢...
0x0D: key=key1+4; break; case 0x0B: key=key1+8; break; case 0x07: key=key1+12; break; default : key=-1; } if((key1+1)&&(key+1)) disbuf=key;}void ejjc() \/\/判断是否按键{P1=0xF0;if(P1!=0xF0)scan();}void main(){while(1){ejjc();P3=LED7Code[...

...是敲击了左control键还是右control键?请高手指点,谢谢!
'找出最小的元素序号 If sngsq(j) < sngsq(intmin) Then intmin = j Next j '将找出的最小元素与第i个元素交换 sngt = sngsq(i)sngsq(i) = sngsq(intmin)sngsq(intmin) = sngt Next i '打印输出 For i = 1 To n Print sngsq(i); '不换行输出 Next i ...

急求高手指点,excel中,VB编辑出现错误,望高手看看是不是语法有错误,如...
IF colItems="00;d8;d5;39;c5;c2"The 应该是 IF colItems="00:d8:d5:39:c5:c2"Then 间隔是冒号而不是分号 还有是Else,不是Eles

相似回答
大家正在搜