当前位置 博文首页 > vbs判读盘符被双击的脚本

    vbs判读盘符被双击的脚本

    作者:admin 时间:2021-02-18 18:40

    复制代码 代码如下:

    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

    js
下一篇:没有了