VBS错误消息 - “行:6,列:1,错误:( null),代码:800401E4,来源:(null)”

时间:2011-05-18 10:09:28

标签: vbscript autoit

我是脚本新手,偶然发现了我想亲自评估的AutoIt(以及其他脚本技术)。有没有人在这段代码中看到任何错误(我无法确定这是一个VBS错误还是我对AutoIt不了解的一些错误)?

我正在使用名为VbsEdit的编辑器,我收到如下错误消息: “行:6,列:1,错误:( null),代码:800401E4,来源:( null)”

所有帮助表示赞赏。 TIA


'Start AutoIt server script first

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "h:\AutoItServer.exe" 

Set oAutoIt = GetObject("AutoIt.Application") ' the magic

WS_OVERLAPPEDWINDOW = &H00CF0000

hGui = oAutoIt.Call("GUICreate", "VBS AutoIt GUI test", -1, -1, -1, -1, WS_OVERLAPPEDWINDOW)
hButton = oAutoIt.Call("GUICtrlCreateButton", "Click", 100, 100, 100, 30)
hButton2 = oAutoIt.Call("GUICtrlCreateButton", "Click me too", 100, 300, 100, 30)

oAutoIt.Call "WinSetOnTop", "VBS AutoIt GUI test", "", 1

AW_FADE_IN  = &H00080000
oAutoIt.Call "DllCall", "user32.dll", "bool", "AnimateWindow", "hwnd", hGui, "dword", 1000, "dword", AW_FADE_IN

oAutoIt.Call "GUISetState"

Do
    Select Case oAutoIt.Call("GUIGetMsg")
        Case -3
            Exit Do
        Case hButton
            oAutoIt.Call "MsgBox", 262144+32+3, "Title", "Bzzz bzz bzzzz", 0, hGUI
        Case hButton2
            oAutoIt.Call "Beep", 500, 700
    End Select
    Wscript.Sleep(10)
Loop

oAutoIt.Call "GUIDelete"

If oAutoIt.Call("MsgBox", 4 + 48 + 262144, "?", "Kill server?") = 6 Then oAutoIt.Quit

1 个答案:

答案 0 :(得分:1)

问题是您在完全初始化之前尝试获取对象。 (在魔法发生的那一行)

尝试WshShell.Run "h:\AutoItServer.exe", 1, true这会使脚本等到autoitserver启动。