求助VB语言,希望每隔10秒钟运行一次ALT+8键,一直循环,我写的不行,一运行就死机。 20
PrivateDeclareSubSleepLib"kernel32"(ByValdwMillisecondsAsLong)PrivateSubCommand1_Clic...
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
ExitLoop = False
Do
SendKeys "%8"
Sleep 5000
Loop
End Sub 展开
Private Sub Command1_Click()
ExitLoop = False
Do
SendKeys "%8"
Sleep 5000
Loop
End Sub 展开
3个回答
展开全部
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
ExitLoop = False
Do
SendKeys "%8"
'用一下doevents比较可靠
doevents
Sleep 5000
Loop
End Sub
'以下的写法更合理
Private Sub Command1_Click()
ExitLoop = False
Do
SendKeys "%8"
'这里sleep 5000改变一下,免得卡死太长时间
for i=1 to 50
doevents
if ExitLoop then exit do
Sleep 100
next
Loop
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询