错误:需要对象:HTA 中的“wscript" [英] Error: Object required: 'wscript' in HTA

查看:19
本文介绍了错误:需要对象:HTA 中的“wscript"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找,但似乎找不到答案.我正在制作一个基于 gui 的程序选择器,我对 VBS 和 HTA 还很陌生.我做了一个自动打字机,但我似乎无法弄清楚为什么它在 HTA 中不起作用.它自己工作得很好.

I've been searching for awhile, but I cannot seem to find the answer. I am making a gui based program selector and I am quite new to VBS and HTA. I've made a auto-typer and I cannot seem to figure out why it does not work in HTA. It works fine on its own.

<head>
<title>Gui Bases Program Selector.</title>
<HTA:APPLICATION 
     APPLICATIONNAME="HTA Test"
     SCROLL="yes"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="maximize"
>
</head>

<script language="VBScript">
Sub TestSub
    Set shell = CreateObject("wscript.shell") 
    strtext  = InputBox("What Do you want your message do be?")
    strtimes = InputBox ("How many times would you like you type it?")
    If Not IsNumeric(strtimes) Then
        lol = MsgBox("Error = Please Enter A Number.") 
        WScript.Quit
    End If
    MsgBox "After you click ok the message will start in 5 seconds "
    WScript.Sleep(5000)
    Tor i=1 To strtimes
        shell.SendKeys(strtext & "")
        shell.SendKeys "{Enter}"
        WScript.Sleep(75)
    Next
End Sub
</script>

<body>
<input type="button" value="AutoTyper" name="run_button"  onClick="TestSub"><p> 
</body>

推荐答案

HTA 引擎不提供 WScript 对象,因此诸如 WScript.QuitWScript.Sleep 在 HTA 中不起作用.要以编程方式退出 HTA,请使用 Self.Closewindow.Close.要替换 Sleep 方法,请参阅这个问题的答案.

The HTA engine doesn't provide a WScript object, so things like WScript.Quit or WScript.Sleep don't work in HTAs. To programmatically exit from an HTA use Self.Close or window.Close. For replacing the Sleep method see the answers to this question.

这篇关于错误:需要对象:HTA 中的“wscript"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆