实现代码如下:

do while true 
set WshShell = WScript.CreateObject("WScript.Shell") 
IF WshShell.AppActivate("D:\") Then 
MsgBox "ok" 
wscript.quit 
End If 
loop 

试都不要试,就知道这段代码是错误的。因为WshShell.AppActivate考虑的是窗体的Caption中包含的字符或字符串,你用WshShell.AppActivate("D:\")这个,就是说窗体Caption里要包含"D:\"这个字符串。可你打开D盘看看,是这样的吗?都是“本地磁盘(D:)”。如果有卷标,那更说不准。所以应该写成WshShell.AppActivate("(D:)"),考虑到内存节约的问题,应该这样写:

set WshShell = WScript.CreateObject("WScript.Shell")
do 
IF WshShell.AppActivate("(D:)") Then
MsgBox "ok"
wscript.quit
End If
loop

以上就是【vbs判读盘符被双击的脚本】的全部内容了,欢迎留言评论进行交流!

赞(0) 踩(0)
发表我的评论

最新评论

  1. 暂无评论