import win.ui; import web.form; /*DSG{{*/ var winform = win.form(parent=...; bottom=523;scroll=1;right=744;text="演示表單上傳控件賦值";cls="DLG_WEB" ) winform.add( ) /*}}*/ //創(chuàng)建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創(chuàng)建一個(gè)函數(shù)鉤子,攔截網(wǎng)頁對(duì)文件對(duì)話框的調(diào)用,<br /> 并直接返回我們預(yù)設(shè)的值即可。</p> </body> </html> ***/ wb.write(html) //顯示窗體 winform.show() wb.wait();//等待指定網(wǎng)址,可以使用模式匹配語法 //導(dǎo)入函數(shù)鉤子支持庫 import raw.apiHook; //聲明鉤子需要用到的結(jié)構(gòu)體 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; } //鉤子函數(shù) 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();//用完立即卸載鉤子,但是這里必須用一個(gè)異步的延時(shí)函數(shù),讓鉤子函數(shù)可以先返回再銷毀 },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() //進(jìn)入消息循環(huán) win.loopMessage(); |
聯(lián)系客服