网站百度百科怎么做,app公司网站模板,app推广活动策划方案,高端建站选哪家webPageOperation是webview的初步封装#xff0c;用来网页填表、操作网页。可操作web.form、web.view、web.view2等浏览器组件。
使用方法
首先把webPageOperation.aardio#xff08;源码在后面#xff09;放到~\lib\godking目录下#xff0c;然后新建窗口项目#xff…webPageOperation是webview的初步封装用来网页填表、操作网页。可操作web.form、web.view、web.view2等浏览器组件。
使用方法
首先把webPageOperation.aardio源码在后面放到~\lib\godking目录下然后新建窗口项目
import win.ui;
/*DSG{{*/
var winform win.form(textaardio form;right759;bottom469)
winform.add(
button{clsbutton;text打开网页;left220;top400;right340;bottom450;z2};
button2{clsbutton;text搜索;left410;top400;right530;bottom450;z3};
custom{clscustom;text自定义控件;left9;top13;right744;bottom386;ah1;aw1;z1}
)
/*}}*/import web.view
import console
var wb web.view(winform.custom)
wb.go(https://www.sogou.com/)winform.button.oncommand function(id,event){import godking.webPageOperation;var wpo godking.webPageOperation(wb);// 点击图片连接var s #weixinch;wpo.bySelector( s ).click();
}winform.button2.oncommand function(id,event){import godking.webPageOperation;var wpo godking.webPageOperation(wb);// 填写搜索框内容var s #query;wpo.bySelector( s ).setValue(光庆aardio);// 表单提交var tagname formwpo.byTagNameS( tagname,1 ).submit();
}winform.show();
win.loopMessage();组件源码
//webPageOperation 网页操作
//光庆封装 http://chengxu.online
//V1.1.1
//2023-06-05
//参考文档 https://developer.mozilla.org/zh-CN/docs/Web/API
/*
更新日志1.1.1 改进S结尾的操作集合增加 byIndex() 函数改进 byChildS() 和 byParent() 函数命名。1.1.0 支持 parentNode() 父元素操作集 和 childNodes() 子元素操作集。内置find函数可寻找指定元素并返回操作集但速度很慢。1.0.0 初步封装
Selector(CSS选择器)参考手册: https://www.runoob.com/cssref/css-selectors.htmlhttps://m.w3cschool.cn/cssref/css-selectors.html
bySelector(querySelector)使用文档https://www.runoob.com/jsref/met-document-queryselector.html https://m.w3cschool.cn/jsref/met-element-queryselector.html
*/
namespace godking// 对象操作类
class_func class {ctor( webview,funcName,Selector,index,childNodes,childIndex){if index this.index [ (index-1) ] else this.index ;if childIndex this.childIndex [ (childIndex-1) ] else this.childIndex ;var childNodesIndex childNodes this.childIndex;};getProp function(Prop){Prop:value;return webview.eval(document. funcName ( Selector ) this.index childNodesIndex . Prop);}setProp function(Prop,v){Prop:value;if type(v)type.string v v ;return webview.doScript(document. funcName ( Selector ) this.index childNodesIndex . Prop v);} count function(){var t;if childNodes {t webview.eval(document. funcName ( Selector ) this.index childNodes);}else{t webview.eval(document. funcName ( Selector ));}if type(t) type.table return ..table.count(t);else return 0;}click function(){return webview.doScript(document. funcName ( Selector ) this.index childNodesIndex .click());}submit function(){return webview.doScript(document. funcName ( Selector ) this.index childNodesIndex .submit());}getValue function() { return this.getProp(value) }; setValue function(v) { return this.setProp(value,v) }; getText function() { var t this.getProp(value); if t!null return tostring(t); }; setText function(v) { return this.setProp(value,tostring(v)) }; getChecked function() { return this.getProp(checked) }; setChecked function(v1) { return this.setProp(checked,v?1:0) }; getInnerText function() { return this.getProp(innerText) }; setInnerText function(v) { return this.setProp(innerText,v) }; getOuterText function() { return this.getProp(outerText) }; setOuterText function(v) { return this.setProp(outerText,v) }; getOuterHTML function() { return this.getProp(outerHTML) }; setOuterHTML function(v) { return this.setProp(outerHTML,v) }; getInnerHTML function() { return this.getProp(innerHTML) }; setInnerHTML function(v) { return this.setProp(innerHTML,v) }; getSelectedItemIndex function(){var idx this.getProp(selectedIndex); if idx!null return idx1; }setSelectedItemByIndex function(v){v:1; v-1; return this.setProp(selectedIndex,v)}getSelectedItemText function(){var idx this.getProp(selectedIndex); if idxnull return ; return webview.eval(document. funcName ( Selector ) this.index childNodesIndex .options.item( idx ).text);}setSelectedItemByText function(v){for(i1;this.count();1){if webview.eval(document. funcName ( Selector ) this.index childNodesIndex .options.item( (i-1) ).text)v {return webview.doScript(document. funcName (Selector) this.index childNodesIndex .selectedIndex (i-1));}}} getItemText function(v){v:1; v-1;return webview.eval(document. funcName ( Selector ) this.index childNodesIndex .options.item( v ).text);} getItemCount function(){var t webview.eval(document. funcName ( Selector ) this.index childNodesIndex .options);if type(t)type.table return ..table.count(t); } getName function() { return this.getProp(name) }; getID function() { return this.getProp(id) }; getHref function() { return this.getProp(href) }; getSrc function() { return this.getProp(src) }; getTag function() { return this.getProp(tagName) }; getType function() { return this.getProp(type) }; getClass function() { return this.getProp(className) }; getStyle function() { return this.getProp(style) }; setHref function(v) { return this.setProp(href,v) }; setSrc function(v) { return this.setProp(src,v) }; setTag function(v) { return this.setProp(tagName,v) }; setType function(v) { return this.setProp(type,v) }; setClass function(v) { return this.setProp(className,v) }; setStyle function(v) { return this.setProp(style,v) }; byParent function(){return ..godking.class_func(webview,funcName,Selector,index,childNodes this.childIndex .parentNode,null); }byChildS function(v){return ..godking.class_func(webview,funcName,Selector,index,childNodes this.childIndex .childNodes,v:1); }focus function(){webview.doScript(document. funcName ( Selector ) this.index childNodesIndex .focus());}byIndex function(v){if childIndex return ..godking.class_func( webview,funcName,Selector,index,childNodes,v:1); else return ..godking.class_func( webview,funcName,Selector,v:1,childNodes,childIndex); }}class webPageOperation {ctor(webview){}; // 获取对象函数focus function(){webview.focus();}getProp function(prop){return webview.eval(document.prop);}setProp function(prop,v){if type(v)type.string vv;return webview.doScript(document.propv);}hideScrollbar function(){webview.doScript(document.body.style.overflowhidden;document.body.style.overflowXhidden;document.body.style.overflowYhidden;document.parentWindow.execScript(document.body.style.overflowhidden;))}hideBoder function(){webview.doScript(document.body.style.border0px none #CCCCCC;)}addLimit function(){webview.doScript(document.οncοntextmenufunction(){return false;};document.onselectstartfunction(){return false;};document.onsdragstartfunction(){return false;};)}getTitle function(){return webview.eval(document.title);}getCookie function(){return webview.eval(document.cookie);} setDesignMode function(vtrue){webview.doScript(document.designMode(v?on:off))}back function(){webview.doScript(window.history.back();)}forward function(){webview.doScript(window.history.forward();)}find function(kv){var fd function(clss,fd){for(i1;clss.childNodes().count();1){// 检查当前子对象var curChd clss.childNodes(i);var is true;for(k,v in kv){if curChd.getProp(k)!v {isfalse;break;}}if is return curChd; // 如果有子子对象则深入分析当前子对象if curChd.childNodes().count() {var r fd(curChd,fd);if r return r; }} }var cls this.bySelector(html);if !cls.childNodes().count() cls this.bySelector(body);if cls.childNodes().count() return fd(cls,fd); }// 创建对象操作类实例函数byID function(v){ return ..godking.class_func(webview,getElementById,v) };bySelector function(v){ return ..godking.class_func(webview,querySelector,v) };byTagNameS function(v,index){ return ..godking.class_func(webview,getElementsByTagName,v,index:1) };byNameS function(v,index){ return ..godking.class_func(webview,getElementsByName,v,index:1) };byClassNameS function(v,index){ return ..godking.class_func(webview,getElementsByClassName,v,index:1) };bySelectorS function(v,index){ return ..godking.class_func(webview,querySelectorAll,v,index:1) };}/**intellisense()
godking.webPageOperation 网页操作类
godking.webPageOperation( wb ) 初始化网页操作类。参数webform、webview、webview2 对象
godking.webPageOperation() !godking_webPageOperation.
end intellisense**//**intellisense(!godking_webPageOperation.)
byID( __ ) 通过ID获取元素对象创建对象操作集。
bySelector( __ ) 通过Selector路径获取元素对象创建对象操作集。
byTagNameS( __, 1 ) 通过TagName获取元素对象集合创建对象操作集。\n参数1tagName参数2对象索引从1开始
byNameS( __, 1 ) 通过name获取元素对象集合创建对象操作集。\n参数1name参数2对象索引从1开始
byClassNameS( __, 1 ) 通过ClassName获取元素对象集合创建对象操作集。\n参数1ClassName参数2对象索引从1开始
bySelectorS( __, 1 ) 通过Selector路径获取元素对象集合创建对象操作集。\n参数1Selector路径参数2对象索引从1开始byID() !godking_webPageOperation_class.
bySelector() !godking_webPageOperation_class.
byTagNameS() !godking_webPageOperation_class.
byNameS() !godking_webPageOperation_class.
byClassNameS() !godking_webPageOperation_class.
bySelectorS() !godking_webPageOperation_class.getProp( __ ) 获取属性值。参数属性名
setProp( __, ) 设置属性值。参数属性名、属性值
hideScrollbar() 隐藏滚动条
hideBoder() 隐藏边框
addLimit() 添加鼠标右键菜单、选择文本、拖拽的限制。
getTitle() 获取标题
getCookie() 获取cookie
setDesignMode( true ) 设置设计模式编辑模式
back() 后退
forward() 前进
focus() 网页组件获取输入焦点
end intellisense**//**intellisense(!godking_webPageOperation_class.)
getProp( __ ) 获取属性值。参数属性名
setProp( __, ) 设置属性值。参数属性名、属性值count() 元素总数量。by开头S结束的函数可以通过该函数获取总元素数量。
click() 点击元素
submit() 提交表单
focus() 网页元素获取输入焦点getValue() 取value值
setValue( __ ) 置value值getText() 取value值自动tostring转文本。
setText( __ ) 置value值自动tostring转文本。getChecked() 取选中状态
setChecked( true ) 置选中状态getInnerText() 取innerText
setInnerText( __ ) 置innerTextgetOuterText() 取outerText
setOuterText( __ ) 置outerTextgetOuterHTML() 取outerHTML
setOuterHTML( __ ) 置outerHTMLgetInnerHTML() 取innerHTML
setInnerHTML( __ ) 置innerHTMLbyChildS( 1 ) 创建子元素对象操作集。参数子元素索引。
byChildS() !godking_webPageOperation_class.
byParent() 创建父元素对象操作集。\n!godking_webPageOperation_class.
byIndex( 1 ) 创建当前元素集(S结尾的)的指定索引的元素的操作集。参数元素索引。
byIndex() !godking_webPageOperation_class.getSelectedItemIndex() 取选择框当前选中项目索引
setSelectedItemByIndex( __ ) 置选择框当前选中项目索引
getSelectedItemText() 取选择框当前选中项目文本
setSelectedItemByText( __ ) 置选择框当前选中项目文本
getItemText( __ ) 取指定项目文本。参数项目索引(从1开始)
getItemCount() 取项目数量
getName() 取name
getID() 取id
getHref() 取href
getSrc() 取src
getTag() 取tagName
getType() 取type
getClass() 取class
getStyle() 取stylesetHref( __ ) 置href
setSrc( __ ) 置src
setTag( __ ) 置tagName
setType( __ ) 置type
setClass( __ ) 置class
setStyle( __ ) 置styleend intellisense**/参考
https://blog.csdn.net/sdlgq/article/details/131011599