【问题标题】:SendKeys isn't working with variablesSendKeys 不适用于变量
【发布时间】:2019-07-28 21:53:51
【问题描述】:

为了使用SendKeys 方法,我编写了一个非常简单的VBS 程序,以便其他程序可以调用它。当我只是写出一个简单的字符串来测试它时:

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.SendKeys "testing"

它工作得很好。但是当我使用等价变量代替字符串时:

Set WshShell = WScript.CreateObject("WScript.Shell")
Set thingy = "testing"

WshShell.SendKeys thingy

调用时会报如下错误:

【问题讨论】:

    标签: variables vbscript runtime-error sendkeys


    【解决方案1】:

    问题在于set thingy = "testing",而不是SendKeysSet statements 用于将对象分配给变量。它们不得用于分配原始数据类型。

    请改用thingy = "testing"

    【讨论】:

    • 我不明白。因为我没有使用Set
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-18
    • 2015-03-14
    • 1970-01-01
    • 1970-01-01
    • 2020-05-04
    • 1970-01-01
    相关资源
    最近更新 更多