项目中遇到需要自动登录功能,想着用机器人实现。所以有了这篇博客,记录下基本用法。
下载uibot creator
下载链接:https://www.uibot.com.cn/
使用
插件安装
若使用uibot操作火狐或者谷歌浏览器,需要给浏览器装插件。
功能实现
此处实现的功能如下:程序运行,自动打开chrome,打开百度,搜索uibot。
点击流程块右上角的编辑按钮
从左侧树形菜单将将要实现的功能拖到右侧即可。
此处的核心功能用js实现
源码:
Dim sRet = ""
Dim bRet = ""
Dim iRet = ""
Dim hWeb = ""
hWeb = WebBrowser.Create("chrome","www.baidu.com",30000,{"bContinueOnError":False,"iDelayAfter":300,"iDelayBefore":200,"sBrowserPath":"","sStartArgs":""})
TracePrint hWeb
sRet = WebBrowser.RunJS(hWeb,'''function(){
document.getElementById('kw').value = 'uibot';
document.getElementById('su').click();
return 123;
}''',True,{"bContinueOnError":False,"iDelayAfter":300,"iDelayBefore":200})
点击运行即可实现功能。