以下代码在Windows 10之前工作,在Internet Explorer中打开htm文件,设置为特定大小和屏幕位置。现在在Windows 10和IE11中我弹出多个错误,IE框的大小和位置都不是大小。有什么建议吗?
批处理文件
Main()
Sub Main()
Force32bit()
Dim objExplorer : Set objExplorer = CreateObject("InternetExplorer.Application")
objExplorer.Navigate "G:\operational.htm"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Width = 280
objExplorer.Height = 1160
objExplorer.Left = 1645
objExplorer.Top = 0
objExplorer.Visible = 1
objExplorer.Menubar = 0
objExplorer.Resizable = 1
End Sub
Sub Force32bit()
If InStr(UCase(WScript.FullName), "SYSTEM32") > 0 and CreateObject("Scripting.FileSystemObject").FolderExists("C:\Windows\SysWOW64") Then
Dim objShell : Set objShell = CreateObject("WScript.Shell")
objShell.CurrentDirectory = "C:\Windows\SysWOW64"
objShell.Run "wscript.exe " & Chr(34) & WScript.ScriptFullName & Chr(34), 1, False
End If
End Sub
operational.htm
这是一个简单的HTML文档,其中包含指向本地驱动器和Internet上资源的快捷方式链接。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Operator</title>
<link rel="stylesheet" href="../css/styles.css" type="text/css" />
<script type="text/javascript">
tday =new Array("Sun","Mon","Tues","Wed","Thurs","Fri","Sat");
tmonth=new Array("Jan","Feb","March","Apr","May","June","July","Aug","Sept","Oct","Nov","Dec");
function GetClock(){
d = new Date();
nday = d.getDay();
nmonth = d.getMonth();
ndate = d.getDate();
nyear = d.getYear();
nhour = d.getHours();
nmin = d.getMinutes();
if(nyear<1000) nyear=nyear+1900;
if(nmin <= 9){nmin="0"+nmin}
<!--+(nmonth+1)+-->
document.getElementById('clockbox').innerHTML=""+nhour+":"+nmin+"hrs "+tday[nday]+", "+ndate+" "+tmonth[nmonth]+" "+nyear+"";
setTimeout("GetClock()", 1000);
}
window.onload=GetClock;
</script>
<script type="text/javascript">
function hideshow(which){
if (!document.getElementById)
return
if (which.style.display=="block")
which.style.display="none"
else
which.style.display="block"
}
</script>
</head>
<body class="body">
<div id="clockbox""></div>
<br><B>MENU</b>
<h1>Options</h1>
....
</body></html>
我尝试使用此代码进行测试但遇到Windows脚本宿主错误第8行Char 1'未指定错误'错误代码80004005。
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Visible = True
objIE.Navigate "testing.htm"
objIE.ToolBar = 0
objIE.Menubar = 1
objIE.StatusBar = 0
objIE.Width = 280
objIE.Resizable = 1
objIE.Height = 600
objIE.Top = 10
On Error Resume Next
Do
If objIE.ReadyState = 4 Then
If Err = 0 Then
Exit Do
Else
Err.Clear
End If
End If
WScript.Sleep 10
Loop
On Error Goto 0