aardio 官方社区

 找回密码
 注册会员

QQ登录

只需一步,快速开始

搜索
查看: 11338|回复: 0

上传控件的钩子怎么能改选择多个文件的啊

[复制链接]

12

主题

40

回帖

424

积分

二级会员

积分
424
发表于 2018-6-1 15:20:29 | 显示全部楼层 |阅读模式

论坛http://bbs.aardio.com/forum.php? ... ;tid=289&extra=中一个代码,通过钩子可以设置html中file控件的上传文件,但这个帖子中代码是只是设置一个文件,如果是想设置多个文件应该怎么办呢?

以下代码是整理过的,方便各位测试

  1.         import win.ui;
  2.         import web.form;
  3.         /*DSG{{*/
  4.         var winform = win.form( bottom=523;scroll=1;right=744;text="演示表单上传控件赋值";cls="DLG_WEB" )
  5.         winform.add(  )
  6.         /*}}*/
  7.         var wb = web.form( winform );
  8.         wb.noScriptErr=true;       
  9.         wb.html = /**
  10.         <!doctype html>
  11.         <html>
  12.         <body>
  13.             <form>
  14.                     <input type="file" name="filename" multiple="multiple"  style="width:1000px"  /><br>
  15.                 </form>
  16.         </body>
  17.         </html>
  18.         **/
  19.         winform.show();
  20.         wb.wait();
  21.         import raw.apiHook;
  22.         class OPENFILENAMEW{
  23.                 INT structSize;
  24.                 INT hwndOwner;
  25.                 pointer instance ;
  26.                 pointer filter;
  27.                 pointer customFilter;
  28.                 INT maxCustFilter;
  29.                 INT filterIndex;
  30.                 pointer file ;
  31.                 INT maxFile;
  32.                 pointer fileTitle;
  33.                 INT maxFileTitle;
  34.                 pointer initialDir;
  35.                 pointer title;
  36.                 INT flags;
  37.                 WORD fileOffset;
  38.                 WORD fileExtension;
  39.                 pointer defExt;
  40.                 pointer lCustData;
  41.                 pointer lpfnHook;
  42.                 pointer lpTemplateName;
  43.                 pointer pvReserved;
  44.                 INT dwReserved;
  45.                 INT flagsEx;
  46.         }
  47.         hookGetOpenFileNameW = raw.apiHook("comdlg32.dll", "GetOpenFileNameW", "int(pointer)",
  48.                 function (pfn) {                       
  49.                     var oldofn = raw.convert(pfn ,OPENFILENAMEW() );
  50.                     path = ..string.toUtf16("D:\screen.bmp" ); //注意必须是确实存在的路径
  51.                     ::CopyMemory(  oldofn.file,path,#path );
  52.                     winform.setTimeout(
  53.                         function(){
  54.                             hookGetOpenFileNameW.unInstall();//用完立即卸载钩子,但是这里必须用一个异步的延时函数,让钩子函数可以先返回再销毁
  55.                                
  56.                         },1
  57.                     )   
  58.                     return 1;
  59.                 }
  60.         ).install();
  61.         ele = wb.getEle("filename");
  62.         ele.click();
  63.         win.loopMessage();
复制代码
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

手机版|未经许可严禁引用或转载本站文章|aardio.com|aardio 官方社区 ( 皖ICP备09012014号 )

GMT+8, 2025-1-19 15:09 , Processed in 0.055761 second(s), 22 queries .

Powered by Discuz! X3.5

Copyright © 2001-2024 Tencent Cloud.

快速回复 返回顶部 返回列表