脚本之家,脚本语言编程技术及教程分享平台!
分类导航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服务器之家 - 脚本之家 - VBS - vbs判读盘符被双击的脚本

vbs判读盘符被双击的脚本

2020-07-23 11:14VBS脚本之家 VBS

你用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

 

延伸 · 阅读

精彩推荐