所以我尝试将ScriptGUI(来自here)用于我的.bat
文件,但它没有文件选择器,所以我尝试添加一个。
我只是复制并重命名了一些代码,除了为子功能添加另一个变量外,它似乎也有效。
' build a file selector
ElseIf UCase(strSplit(0)) = "FILE" Then
strHTML = strHTML & Build_File(strLabel,id,Replace(strLabel," ",""),strSplit(2))
' store the batch file in the arrControls array
arrControls(id) = "file,none"
id = id + 1
>
问题似乎是这里的代码"Click_File(" & fiId & "," & fiFilter & ")"
Function Build_File(fiLabel, fiId, fiName, fiFilter)
' Construct a file selector
Dim strHTML
strHTML = "<input class='button' type='button' name='" _
& fiName & "' value='" & fiLabel & "' id='" & fiId _
& "' onClick=" & chr(34) & "Click_File(" & fiId & "," & fiFilter & ")" & chr(34) _
& " onMouseOver=" & chr(34) & fiName & ".className='button btnhov'" & chr(34) _
& " onMouseOut=" & chr(34) & fiName & ".className='button'" & chr(34) _
& ">"
strHTML = strHTML & " <input type='text' readonly='readonly' value='none' name='fi" & fiName & "' id='fi" & fiId & "'/> "
Build_File = strHTML
End Function
&GT;
Sub Click_File(strId, fiFilter)
' open a file selector
set objShell= CreateObject("WSCript.Shell")
myCur = objShell.CurrentDirectory
Dim file
file = GetFileName(myCur, fiFilter)
arrControls(strId) = "file," & file
document.getElementById("fi" & strId).value = file
document.getElementById("fi" & strId).size = Len(file) + 2
End Sub
它告诉我在调用子时不能使用括号。
有什么想法吗?
编辑:新问题,
我正在使用Rob van der Woude的脚本来打开文件对话框(来自here的顶部帖子),这显然应该在hta中工作但是我收到一条错误消息“ActiveX组件无法创建对象:'UserAccounts.CommonDialog'“
答案 0 :(得分:0)
嗯,这条消息并没有错。在调用Sub
时,无法使用括号。
从以下位置更改此行:
& "' onClick=" & chr(34) & "Click_File(" & fiId & "," & fiFilter & ")" & chr(34) _
为:
& "' onClick=" & chr(34) & "Click_File " & fiId & "," & fiFilter & chr(34) _
并查看是否能解决您的问题。