import win.ui; import web.form; /*DSG{{*/ var winform = win.form(parent=...; bottom=523;scroll=1;right=744;text="演示表单上传控件赋值";cls="DLG_WEB" ) winform.add( ) /*}}*/ //创建web窗体 var wb = web.form( winform ); html =/*** <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>演示表单上传控件赋值</title> </head> <body> <form id="form1" name="form1" enctype="multipart/form-data" method="post" action=""> <label for="upload0"></label> <input type="file" name="upload0" id="upload0" /> </form> <p>文件上传控件的值是只读的,不能修改.<br /> 这里使用AAuto中的raw.hookApi创建一个函数钩子,拦截网页对文件对话框的调用,<br /> 并直接返回我们预设的值即可。</p> </body> </html> ***/ wb.write(html) //显示窗体 winform.show() wb.wait();//等待指定网址,可以使用模式匹配语法 //导入函数钩子支持库 import raw.apiHook; //声明钩子需要用到的结构体 OPENFILENAMEW = class{ INT structSize; INT hwndOwner; pointer instance ; pointer filter; pointer customFilter; INT maxCustFilter; INT filterIndex; pointer file ; INT maxFile; pointer fileTitle; INT maxFileTitle; pointer initialDir; pointer title; INT flags; WORD fileOffset; WORD fileExtension; pointer defExt; pointer lCustData; pointer lpfnHook; pointer lpTemplateName; pointer pvReserved; INT dwReserved; INT flagsEx; } //钩子函数 GetOpenFileNameW_Hook = function (pfn) { var oldofn = raw.convert(pfn ,OPENFILENAMEW() ); path = ..string.toUnicode("C:\神马都是浮云.exe"); ::CopyMemory( oldofn.file,path,#path ); winform.setTimeout( function(){ hook.unInstall();//用完立即卸载钩子,但是这里必须用一个异步的延时函数,让钩子函数可以先返回再销毁 },1 ) return 1; } //安装API钩子 hook = raw.apiHook("comdlg32.dll", "GetOpenFileNameW", GetOpenFileNameW_Hook, "int(pointer)").install(); /** <INPUT class=text3 type=file name=upload0> **/ var ele = wb.getEle("upload0") ele.click() //进入消息循环 win.loopMessage(); |
联系客服