WScript.Shell模拟键盘输入中文的问题 因为sendkeys是把按键的顺序存起来,然后当JS运行完了以后一次性执行,所以你的CTRL+V复制的就是内存中最后一次复制的值 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <html><head> <title></title><script>function clearTest(len){for(i=1;i<=len;i++){var obj = eval("document.form1.fileName"+i);obj.select();document.execCommand("delete")}}function onTest(len){clearTest(len)form1.fileName1.focus()for(i=1;i<=len;i++){var srcValue=i+"测试.jpg";var WshShell = new ActiveXObject("Wscript.Shell");//try{//obj.focus();WshShell.SendKeys(srcValue);WshShell.SendKeys("{TAB}")WshShell.SendKeys("{TAB}")/*}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>昨天也有个人问这个问题,这是斑竹给的答案,你看看吧 对不起啊,看错了刚刚,去掉“测试”确实也是不可以的,你刚刚给我的这个答案在文本框里输出的是: 1\.jpg 2\.jpg 为什么会有“\”这个字符?? 这个东西感觉写WEB程序不是好东西,写CMD程序到是挺好用的,因为里面WScript对象不能用。如果用的话只有这样了<html><head> <title></title><script>function clearTest(len){for(i=1;i<=len;i++){var obj = eval("document.form1.fileName"+i);obj.select();document.execCommand("delete")}}function onTest(len){clearTest(len)form1.fileName1.focus()show(1,len)}function show(i,len){ var srcValue=i+"测试.jpg"; window.clipboardData.clearData("text"); window.clipboardData.setData("text",srcValue); var WshShell = new ActiveXObject("Wscript.Shell"); WshShell.sendkeys("^(v)"); WshShell.SendKeys("{TAB}") WshShell.SendKeys("{TAB}") WshShell.Quit; if(i>len){ return } i++ setTimeout("show('"+i+"','"+len+"')",100)}</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 type="button" onClick="onTest(4);" value="ok"></td></tr></form></table></body></html> 帮写句小小代码 div的下拉列表如何为每项设置个id单击项时要传递 请高人帮忙看下这段JS为何不会输入出表格。。 帮我看看转换的js错在哪里 网页的运行速度问题 小鱼请教大虾一个问题 还请帮忙 谁能告诉我这我下面的代码为什么出错,如何修改,谢谢!(分全部给第一个给出正确答案的大侠) 如何检验输入的数据是数字而非字母或其它字符? 关闭子窗口并向父窗口传递参数的问题? 在javascript中怎么将前后两个日期的天数差为除开了星期6,7的? JS替换字符的简单问题 请教javascript正则表达式
<head>
<title></title>
<script>
function clearTest(len)
{
for(i=1;i<=len;i++){
var obj = eval("document.form1.fileName"+i);
obj.select();
document.execCommand("delete")
}
}
function onTest(len){
clearTest(len)
form1.fileName1.focus()
for(i=1;i<=len;i++){var srcValue=i+"测试.jpg";
var WshShell = new ActiveXObject("Wscript.Shell");
//try{//obj.focus();
WshShell.SendKeys(srcValue);
WshShell.SendKeys("{TAB}")
WshShell.SendKeys("{TAB}")
/*}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>昨天也有个人问这个问题,这是斑竹给的答案,你看看吧
如果用的话只有这样了
<html>
<head>
<title></title>
<script>
function clearTest(len)
{
for(i=1;i<=len;i++){
var obj = eval("document.form1.fileName"+i);
obj.select();
document.execCommand("delete")
}
}
function onTest(len){
clearTest(len)form1.fileName1.focus()
show(1,len)
}
function show(i,len){
var srcValue=i+"测试.jpg";
window.clipboardData.clearData("text");
window.clipboardData.setData("text",srcValue);
var WshShell = new ActiveXObject("Wscript.Shell");
WshShell.sendkeys("^(v)");
WshShell.SendKeys("{TAB}")
WshShell.SendKeys("{TAB}")
WshShell.Quit;
if(i>len){
return
}
i++
setTimeout("show('"+i+"','"+len+"')",100)
}
</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 type="button" onClick="onTest(4);" value="ok">
</td>
</tr>
</form>
</table>
</body>
</html>