前言 官网:https://www.aardio.com/
使用IE内核加载网页 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 import web.form ;var winform = win.form (text="WebBrowser" ;right=1365 ;bottom=767 )winform.add () var wb = web.form ( winform )web.form .gpuRendering (true ,11001 ); wb.go ("https://www.psvmc.cn/zjtools/z/browserinfo/index.html" ); wb.wait (); winform.show (); win.loopMessage ();
弹出页面新窗口打开 主窗口
\main.aardio
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 import web.form ;var winform = win.form (text="IE浏览器" ;right=1365 ;bottom=767 )winform.add ( back_btn={cls="button" ;text="返回" ;left=8 ;top=8 ;right=107 ;bottom=48 ;dl=1 ;dt=1 ;flat=1 ;z=1 }; forward_btn={cls="button" ;text="前进" ;left=112 ;top=8 ;right=211 ;bottom=48 ;dl=1 ;dt=1 ;flat=1 ;z=4 }; home_btn={cls="button" ;text="主页" ;left=216 ;top=8 ;right=316 ;bottom=48 ;dl=1 ;dt=1 ;z=2 }; mwebbrower={cls="custom" ;text="自定义控件" ;left=8 ;top=56 ;right=1360 ;bottom=760 ;db=1 ;dl=1 ;dr=1 ;dt=1 ;z=3 }; refresh_btn={cls="button" ;text="刷新" ;left=320 ;top=8 ;right=420 ;bottom=48 ;dl=1 ;dt=1 ;z=5 } ) winform.forward_btn .disabled =1 ; winform.back_btn .disabled =1 ; winform.show (); winform.enableDpiScaling (); var isDebug = false ;if (isDebug){ io.open (); } var wb = web.form .ie11 ( winform.mwebbrower )web.form .gpuRendering (true ,11000 ); var homepage = "https://www.psvmc.cn/" ;io.print (homepage) wb.go (homepage); wb.wait (); var titleTags = wb.document .getElementsByTagName ("title" )for i, title in com.each (titleTags ) { if (i == 1 ) { winform.text = title.innerHTML ; break ; } } wb.external = { flashISInstall = function ( arg ){ io.print ("Flash是否可用:" ,arg); if (!arg){ var result = winform.msgboxTest ("Flash未安装是否安装" ,"Flash检测" ); if (result){ process.execute_waitInput ("https://www.flash.cn/cdm/latest/flashplayerax_install_cn.exe" ) } } } } var js = wb.document .getScript ().execScript (js); wb.CommandStateChange =function (cmd,enable ) { select (cmd ) { case 0x1 { winform.forward_btn .disabled = !enable } case 0x2 { winform.back_btn .disabled = !enable } } } wb.NewWindow3 =function ( ppDisp, Cancel,dwFlags,bstrUrlContext, bstrUrl ) { var child = winform.loadForm ("/dlg/cwin.aardio" ,winform ); child.setUrl (bstrUrl); return ppDisp,true } winform.forward_btn .oncommand = function (id,event ){ wb.goForward () } winform.back_btn .oncommand = function (id,event ){ wb.goBack () } winform.home_btn .oncommand = function (id,event ){ wb.go (homepage); } winform.refresh_btn .oncommand = function (id,event ){ wb.refresh3 () } win.loopMessage (); return winform;
注意
io.print("cmd:" + cmd , enable )打印的时候,不能让字符串和bool型的拼接,否则不会打印。
winform.loadForm("/dlg/cwin.aardio",winform /*指定父窗口*/ );路径前面不能添加.会导致打包后无法访问页面。
注意如果不设置返回前进按钮的状态,一定要捕获异常
1 2 3 4 5 6 7 8 winform.back_btn .oncommand = function (id,event ){ try { wb.goBack () } catch (e){ io.print (e) } }
弹出的窗口
\dlg\cwin.aardio
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 import web.form ;var winform = win.form (text=" " ;right=1365 ;bottom=767 )winform.add () var wb = web.form ( winform )web.form .gpuRendering (true ,11000 ); winform.wb = wb; winform.show (); winform.enableDpiScaling (); winform.setUrl = function (url ){ wb.go (url) wb.wait () var titleTags = wb.document .getElementsByTagName ("title" ) for i, title in com.each (titleTags ) { if (i == 1 ) { winform.text = title.innerHTML ; break ; } } } wb.NewWindow3 =function ( ppDisp, Cancel,dwFlags,bstrUrlContext, bstrUrl ) { var child = winform.loadForm ("/dlg/cwin.aardio" ,winform ); child.setUrl (bstrUrl); return ppDisp,true } win.loopMessage (); return winform;
弹窗提示 win.msgbox 1、函数原型:
1 win.msgbox ( 消息,标题,样式,父窗口 )
2、函数说明:
除第一个参数以外,其他参数可选。样式默认为 0x2000/_MB_TASKMODAL / 关于样式,请参考:《 aardio WINAPI使用手册 》中的 MessageBox 函数
注意win.msgbox弹出的窗口默认是没有父窗口的, 这就导致用户可以在任务栏切换其他窗口到弹出的消息对话框前面,而消息对话框又阻塞了线程, 导致前置的窗口不能响应用户的任何操作。
win.form类创建的对象提供msgbox成员函数,该函数可自动指定父窗口。 因此在窗体中,推荐使用窗体对象的的msgbox函数 。 如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 import win.ui ; var winform = win.form (parent=...; min=1 ;bottom=249 ;max=1 ;text="aardio Form" ;right=349 )winform.add ( button={ bottom=131 ;text="button" ;left=110 ;right=219 ;top=79 ;z=0 ;cls="button" } ) winform.button .oncommand = function (id,event ){ winform.msgbox ("你不可能把我折腾到父窗体后面去" ) } winform.show (true ) win.loopMessage ();
win.msgboxTest 1、函数原型:
1 ok = win.msgboxTest ( 消息,标题,父窗口 )
2、函数说明:
除第一个参数外,其他参数可选,该函数调用win.msgbox弹出一个带确定按钮、取消按钮的询问对话框,如果用户按确定返回true,否则返回false。
判断安装IE Flash插件 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 import web.form ;var wb = web.form .ie11 ( winform.mwebbrower )web.form .gpuRendering (true ,11000 ); wb.external = { flashISInstall = function ( arg ){ io.print ("Flash是否可用:" ,arg); if (!arg){ var result = winform.msgboxTest ("Flash未安装是否安装" ,"Flash检测" ); if (result){ process.execute_waitInput ("https://www.flash.cn/cdm/latest/flashplayerax_install_cn.exe" ) } } } } var js = wb.document .getScript ().execScript (js);
使用外部浏览器打开页面 1 2 import process;process.openUrl ("https://www.psvmc.cn" )
打开文件 1 2 3 import process;var prcs = process ("/xxx.exe" ,"其他参数" ); prcs.wait ();
注意
process(“/xxx.exe”) 路径第一个字符为斜杠表示应用程序目录,在开发时表示工程目录,在发布后为exe目录
或者
1 2 3 4 5 6 7 8 process.execute ("要执行的程序或网页" ) process.execute_wait ("要执行的程序或网页" ) process.execute_waitInput ("要执行的程序或网页" )
例如
1 process.execute_waitInput ("https://www.baidu.com" )
会直接用浏览器打开。
获取页面标题 1 2 3 4 5 6 7 var titleTags = wb.document .getElementsByTagName ("title" )for i, title in com.each (titleTags ) { if (i == 1 ) { winform.text = title.innerHTML ; break ; } }
单行输入框回车事件 1 2 3 4 5 6 winform.url_tv .wndproc = function (hwnd,message,wParam,lParam ){ if (message == 0x101 && wParam == 0xD ){ win.msgbox ("按了回车!" ); } }
清除缓存 1 2 3 4 5 6 7 8 9 10 11 12 import inet;winform.clean_plus .skin ( background={ default =0x00000000 ; hover=0x22000000 ; disabled=0x00000000 ; } ) winform.clean_plus .oncommand = function (id,event ){ inet.clearCache (); }