vbs判读盘符被双击的脚本
更新时间:2008年07月16日 22:55:54 作者:
你用WshShell.AppActivate("D:\")这个,就是说窗体Caption里要包含"D:\"这个字符串。可你打开D盘看看,是这样的吗?
复制代码 代码如下:
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 TLI.TLIApplication 被遗忘的COM组件
TLI.TLIApplication是一个能获取COM组件Type Library Information(类型库信息)的COM组件。2011-01-01


最新评论