本文主要是介绍【办公类-26-01】20240422 UIBOT网络教研(自动登录并退出多个账号,半自动半人工),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
作品展示:
背景需求:
每学期有多次网络教研
因为我有历任搭档的进修编号和登录密码,
所以每次学习时,我会把历任搭档的任务也批量完成。
但是每次登录都要从EXCEL里复制一位老师的“进修编号”“密码”,还要点击多次按钮,才能登录某位老师的账号进去。
手动复制,容易搞不清楚刚才登录的是哪个账户,是否遗漏人员
我想用UIBOT自动读取EXCEL单元格内容,自动键盘输入“编号”“密码”,实现账户登录,然后手动输入学习内容、感悟、回复的文字。一定程度提高完成的速度。
UIBOT(以管理员身份打开)
C++
Dim objExcelWorkBook,arrayRet,iRet,temp,iPID,hWeb,dictRetobjExcelWorkBook = Excel.OpenExcel('''C:\Users\jg2yXRZ\OneDrive\桌面\20230223进修编号10月刷分.xlsx''',true,"Excel","","")
区域=Excel.ReadRange(objExcelWorkBook,"Sheet1","B2:D13",true)
行=UBound(区域)
TracePrint(行)
For i = 0 To 行 step 1hWeb = WebBrowser.Create("chrome","https://shanghai.3ren.cn/",30000,{"bContinueOnError":false,"iDelayAfter":300,"iDelayBefore":200,"sBrowserPath":"","sStartArgs":""})
Window.Show(@ui"窗口_上海教研在线-GoogleChrome","max")
Delay(1000)
#icon("@res:788c1f60-0099-11ef-9784-0942ecf9a81b.png")
Image.Click({"wnd":[{"cls":"Chrome_WidgetWin_1","title":"上海教研在线 - Google Chrome","app":"chrome"}]},{"x": 0, "y": 0, "width": 0, "height": 0},@res"788c1f60-0099-11ef-9784-0942ecf9a81b.png",0.9,"left","click",10000, {"bContinueOnError": false, "iDelayAfter": 300, "iDelayBefore": 200, "bSetForeground": true, "sCursorPosition": "Center", "iCursorOffsetX": 0, "iCursorOffsetY": 0, "sKeyModifiers": [],"sSimulate": "simulate","sMatchType":"GrayMatch", "iSerialNo": 1})
Delay(1000)
#icon("@res:8ac35c70-0099-11ef-9784-0942ecf9a81b.png")
Image.Click({"wnd":[{"cls":"Chrome_WidgetWin_1","title":"上海教研在线 - Google Chrome","app":"chrome"}]},{"x": 0, "y": 0, "width": 0, "height": 0},@res"8ac35c70-0099-11ef-9784-0942ecf9a81b.png",0.9,"left","click",10000, {"bContinueOnError": false, "iDelayAfter": 300, "iDelayBefore": 200, "bSetForeground": true, "sCursorPosition": "Center", "iCursorOffsetX": 0, "iCursorOffsetY": 0, "sKeyModifiers": [],"sSimulate": "simulate","sMatchType":"GrayMatch", "iSerialNo": 1})
Delay(1000)
#icon("@res:92d9fa90-0099-11ef-9784-0942ecf9a81b.png")
Image.Click({"wnd":[{"cls":"Chrome_WidgetWin_1","title":"CAS – 统一身份认证 - Google Chrome","app":"chrome"}]},{"x": 0, "y": 0, "width": 0, "height": 0},@res"92d9fa90-0099-11ef-9784-0942ecf9a81b.png",0.9,"left","click",10000, {"bContinueOnError": false, "iDelayAfter": 300, "iDelayBefore": 200, "bSetForeground": true, "sCursorPosition": "Center", "iCursorOffsetX": 0, "iCursorOffsetY": 0, "sKeyModifiers": [],"sSimulate": "simulate","sMatchType":"GrayMatch", "iSerialNo": 1})
Delay(1000)
TracePrint(区域[i])
编号 = 区域[i][1]
密码 = 区域[i][2]
Keyboard.InputText(@ui"块级元素<div>_师训号/身份证号/用户名",区域[i][1],true,20,10000,{"bContinueOnError": false, "iDelayAfter": 300, "iDelayBefore": 500, "bSetForeground": true, "sSimulate": "message", "bValidate": false, "bClickBeforeInput": false})Keyboard.InputText(@ui"输入控件<input>",区域[i][2],true,20,10000,{"bContinueOnError": false, "iDelayAfter": 300, "iDelayBefore": 500, "bSetForeground": true, "sSimulate": "message", "bValidate": false, "bClickBeforeInput": false})
Mouse.Drag(826, 598, 1111, 595, "left", [],{"iDelayAfter": 300, "iDelayBefore": 200})#icon("@res:45c72f60-009a-11ef-9784-0942ecf9a81b.png")
Image.Click({"wnd":[{"cls":"Chrome_WidgetWin_1","title":"CAS – 统一身份认证 - Google Chrome","app":"chrome"}]},{"x": 0, "y": 0, "width": 0, "height": 0},@res"45c72f60-009a-11ef-9784-0942ecf9a81b.png",0.9,"left","click",10000, {"bContinueOnError": false, "iDelayAfter": 300, "iDelayBefore": 200, "bSetForeground": true, "sCursorPosition": "Center", "iCursorOffsetX": 0, "iCursorOffsetY": 0, "sKeyModifiers": [],"sSimulate": "simulate","sMatchType":"GrayMatch", "iSerialNo": 1})
Delay(1000)iRet = Dialog.MsgBox("手动完成教研,要推出账户","Laiye Automation",0,1,0)
Mouse.Move(1380, 144, false,{"iDelayAfter": 300, "iDelayBefore": 200})
Delay(1000)
Mouse.Move(1392, 350, false,{"iDelayAfter": 300, "iDelayBefore": 200})
Mouse.Click("left", "click", [],{"iDelayAfter": 300, "iDelayBefore": 300})
Delay(1000)#icon("@res:fefad960-009e-11ef-9784-0942ecf9a81b.png")
Image.Click({"wnd":[{"cls":"Chrome_WidgetWin_1","title":"上海教研在线 - Google Chrome","app":"chrome"}]},{"x": 0, "y": 0, "width": 0, "height": 0},@res"fefad960-009e-11ef-9784-0942ecf9a81b.png",0.9,"left","click",10000, {"bContinueOnError": false, "iDelayAfter": 300, "iDelayBefore": 200, "bSetForeground": true, "sCursorPosition": "Center", "iCursorOffsetX": 0, "iCursorOffsetY": 0, "sKeyModifiers": [],"sSimulate": "simulate","sMatchType":"GrayMatch", "iSerialNo": 1})
Delay(1000)
Next
Excel.CloseExcel(objExcelWorkBook,true)
视频展示:
测试时,没有录屏,等下一次网络教研再录制
感悟:
用了这个代码,输入网址、输入账号和密码、退出浏览器的部分内容可以用程序自动填写(半自动)、按钮暂停后,进行人工做题(半人工)
可减少人工切换页面,复制黏贴、点击按钮的频率,一定程度提高工作效率
这篇关于【办公类-26-01】20240422 UIBOT网络教研(自动登录并退出多个账号,半自动半人工)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!