关于用Wscript.Shell模拟键盘输入的问题,高手请进
网页上有若干file控件,想通过模拟键盘输入给每个file输入值, 模拟键盘输入都没问题,可是值确只输出在最后一个file里面,感觉上是SendKeys方法是从缓存里面全部输出的,不知道怎么解决
代码如下:
<html>
<head>
<title></title>
<script>
function onTest(len){
for(i=1;i<=len;i++){
var obj = eval("document.form1.fileName"+i);
obj.focus();
var srcValue=i+".jpg";
var WshShell = new ActiveXObject("Wscript.Shell");
try{
WshShell.SendKeys(srcValue);
}catch(e){
alert(e);
}
WshShell.Quit;
}
}
</script>
</head>
<body>
<table>
<form name="form1" method="post" action="" enctype="multipart/form-data">
<tr>
<td>
<input name="fileName1" type="file"/>
<input name="fileName2" type="file"/>
<input name="fileName3" type="file"/>
<input name="fileName4" type="file"/>
<input name="fileName5" type="file"/>
<input type="button" onClick="onTest(5);" value="ok">
</td>
</tr>
</form>
</table>
</body>
</html>
期望的结果是:file1控件里面值是1.jpg file2里面是2.jpg ...file5里面是5.jpg
实际结果是:file1至file4都为空,file5里面是全部值:1.jpg2.jpg3.jpg4.jpg5.jpg
请问怎么才能解决这个问题