如何暂停 vbscript 执行? [英] How to pause a vbscript execution?

查看:25
本文介绍了如何暂停 vbscript 执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从内部暂停脚本的执行?类似于 Sleep WinAPI 函数?

How can I pause an execution of a script from within? Something like Sleep WinAPI function?

推荐答案

您可以使用 WScript 对象并调用 Sleep 方法就可以了:

You can use a WScript object and call the Sleep method on it:

Set WScript = CreateObject("WScript.Shell")
WScript.Sleep 2000 'Sleeps for 2 seconds

另一种选择是直接导入和使用WinAPI函数(仅适用于 VBA,感谢 @Helen):

Another option is to import and use the WinAPI function directly (only works in VBA, thanks @Helen):

Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sleep 2000

这篇关于如何暂停 vbscript 执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆