如果按下按钮,则启动文件

时间:2015-10-10 21:47:08

标签: vbscript

我一直在玩下面的剧本:

Set WshShell = CreateObject("WScript.Shell")

intButton = WshShell.Popup ("5 + 5 = 10  yes or no?  if you answer correctly you win a prize!.",5, , 3 + 48)

select case intButton
  case -1
    strMessage = "You did not click any button within the 5 seconds allotted."
  case 6
    strMessage = "click ok to receive your prize!."
  case 7
    strMessage = "wrong no prize!."
  case 2
    strMessage = "ok see ya!."
end select

WshShell.Popup strMessage, , , 64

我希望它能够启动一个.gif文件(单击确定以接收您的奖品)。我尝试在下方输入Wshshell.run "22.gif"(点击“确定”即可获得奖品),但同时启动点击“确定”框和GIF。

我怎样才能让它在点击&#34时启动.gif?好的"?

1 个答案:

答案 0 :(得分:0)

键入时,

strMessage = "click ok to receive your prize!."
Wshshell.run "22.gif" 

您只是设置strMessage变量来保存字符串,并在正下方的行上显示gif。

这是实际显示Popup消息的最后一行代码。

WshShell.Popup strMessage, , , 64

快速解决方法是在每个案例中显示弹出窗口,如下所示。

Set WshShell = CreateObject("WScript.Shell")

intButton = WshShell.Popup ("5 + 5 = 10  yes or no?  if you answer correctly you win a prize!.",5, , 3 + 48)

select case intButton
  case -1
    strMessage = "You did not click any button within the 5 seconds allotted."
    WshShell.Popup strMessage, , , 64
  case 6
    strMessage =  "click ok to receive your prize!."
    WshShell.Popup strMessage, , , 64
    Wshshell.run "22.gif"
  case 7
    strMessage = "wrong no prize!."
    WshShell.Popup strMessage, , , 64
  case 2
    strMessage = "ok see ya!."
    WshShell.Popup strMessage, , , 64
end select


与您的问题没有直接关系,您可以直接在您的代码中嵌入Internet Explorer框架,以完全控制如何显示gif图像,

替换,

Wshshell.run "22.gif"

跟随并调整路径,

Set objExplorer = CreateObject("InternetExplorer.Application")
        With objExplorer
        .Navigate "about:blank"
        .Visible = 1
        .Document.Title = "Show Image"
        .Toolbar=False
        .Statusbar=False
        .Top=400
        .Left=400
        .Height=400
        .Width=400
        .Document.Body.InnerHTML = "<img src='C:\Users\Administrator\Desktop\22.gif'>"
        End With