背景需求:
每年都有一个PATHS课程的“家长问卷调查”和“教师问卷调查”需要填写
作为教师,每次要对全班所有的孩子进行评价,每位孩子64题!
反复点题目,感觉非常累,工作操作就是两位老师,每人做一半孩子的问卷,但也需要很长的时间。
设计需求:
29个孩子,老师要反复点击29*64次,又看有点,又移动鼠标,实在太累了,太烦躁了,很容易最后就随便填写了,影响问卷质量。
所以我想做一个UIBOT,能够读取EXCLE表单,自动点击选择五级量表答案,然后提交。
一、提取题目,制作EXCEL表单
1、复制题目
2、黏贴到TXT内(去除选项的圆圈)
3、黏贴到EXCEL
4、删除从不、偶尔、有时、经常、总是
5、删除空行
6、把竖列变成横列
7、删除A列的题目,差异一列,改成学号和姓名
花了一点时间,把所有的学生的得分输入好
二、写代码
这个代码写了一晚上……
(一)屏幕放大到250%
确保一次只能出现一道题的5个答案
(二)测试每一页64道题目需要移动多少次滚轮
虽然每个题目行数相等
但在测试中,发现固定滚动5次并不能保证64题都正好显示五个选项,通常8题后,就会出现五个选项部分被遮挡的情况。
所以我进过大量测试后,将每道题的滚动次数逐一确定。
这些数字的意思是,模拟鼠标滚动5次,模拟鼠标运动7次。
(三)根据EXCEL数字,读取页面的文字图像,模拟点击
1、读取C2:BN30之间的所有数字
2、如果数字等于1,点击屏幕中的图像“从不”,以此类推
做到64题后,滚轮到页面底部,点击提交
(四)单人64道题完成后,进入下一个孩子的填写页面需要手动
因为29位幼儿信息目录上无法搜索孩子的学号或名字,加上我把页面放大了250%,直接点击下一位孩子的”填写问卷“按钮,也不太可能了,所以这一部分都是手动切换填写页面。
全部代码展示:
Dim temp,arrRet,滚动,iRet,objExcelWorkBook,全部区域,行数,长度,行Rem 滚动次数的列表滚动 = [14]
For i = 1 To 7 step 1滚动=push(滚动,5)Next滚动=push(滚动,6)For i = 1 To 7 step 1滚动=push(滚动,5)Next滚动=push(滚动,7)For i = 1 To 7 step 1滚动=push(滚动,5)Next
For i = 1 To 7 step 1滚动=push(滚动,5)Next滚动=push(滚动,6)For i = 1 To 7 step 1滚动=push(滚动,5)Next滚动=push(滚动,6)For i = 1 To 7 step 1滚动=push(滚动,5)Next滚动=push(滚动,6)For i = 1 To 7 step 1滚动=push(滚动,5)Next滚动=push(滚动,6)For i = 1 To 7 step 1滚动=push(滚动,5)Next滚动=push(滚动,7)TracePrint(滚动)
次=UBound(滚动)TracePrint(次)Rem 63个// Rem 滚动次数
// objExcelWorkBook = Excel.OpenExcel('''C:\Users\jg2yXRZ\OneDrive\桌面\path问卷\paths教师问卷.xlsx''',true,"Excel","","")
// 全部区域=Excel.ReadRange(objExcelWorkBook,"Sheet1","C2:BN30",true)
// 行数=UBound(全部区域)
// TracePrint(行数)// Rem 63个
// For w = 0 To 行数 step 1
// TracePrint(全部区域[w])
// 长度=UBound(全部区域[w])// TracePrint(长度)
// Next
// Rem 滚动次数// For v = 0 To 个 step 1// Mouse.Wheel(个[v],"down", [],{"iDelayAfter":300, "iDelayBefore":200})
// Next
// Excel.CloseExcel(objExcelWorkBook,true)Rem 250%
objExcelWorkBook = Excel.OpenExcel('''C:\Users\jg2yXRZ\OneDrive\桌面\path问卷\paths教师问卷模板(1).xlsx''',false,"Excel","","")
全部区域=Excel.ReadRange(objExcelWorkBook,"Sheet1","C2:BN30",true)
TracePrint(全部区域)
行=Len(全部区域)
TracePrint(行)
Rem 29行=29人
Delay(3000)
For p = 0 To 行-1 step 1
TracePrint(全部区域[p])Rem 【63个数字】【63个数字】
For v = 0 To 次 step 1TracePrint(滚动[v])
Delay(1000)Mouse.Wheel(滚动[v],"down", [],{"iDelayAfter":300, "iDelayBefore":200})
选项数字 = 全部区域[p][v]If 选项数字='1'
#icon("@res:bbebe130-fccc-11ee-b3e3-139b772dd86b.png")
Image.Click({"wnd":[{"cls":"Chrome_WidgetWin_1","title":"问卷清单 - 思智树教师平台 - Google Chrome","app":"chrome"}]},{"x": 0, "y": 0, "width": 0, "height": 0},@res"bbebe130-fccc-11ee-b3e3-139b772dd86b.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})
End If
If 选项数字='2' #icon("@res:ecc9cc40-fccc-11ee-b3e3-139b772dd86b.png")
Image.Click({"wnd":[{"cls":"Chrome_WidgetWin_1","title":"问卷清单 - 思智树教师平台 - Google Chrome","app":"chrome"}]},{"x": 0, "y": 0, "width": 0, "height": 0},@res"ecc9cc40-fccc-11ee-b3e3-139b772dd86b.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})
End If
If 选项数字='3' #icon("@res:08d11740-fccd-11ee-b3e3-139b772dd86b.png")
Image.Click({"wnd":[{"cls":"Chrome_WidgetWin_1","title":"问卷清单 - 思智树教师平台 - Google Chrome","app":"chrome"}]},{"x": 0, "y": 0, "width": 0, "height": 0},@res"08d11740-fccd-11ee-b3e3-139b772dd86b.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})
End IfIf 选项数字='4' #icon("@res:0b09c930-fccd-11ee-b3e3-139b772dd86b.png")
Image.Click({"wnd":[{"cls":"Chrome_WidgetWin_1","title":"问卷清单 - 思智树教师平台 - Google Chrome","app":"chrome"}]},{"x": 0, "y": 0, "width": 0, "height": 0},@res"0b09c930-fccd-11ee-b3e3-139b772dd86b.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})
End IfIf 选项数字='5' #icon("@res:0d166210-fccd-11ee-b3e3-139b772dd86b.png")
Image.Click({"wnd":[{"cls":"Chrome_WidgetWin_1","title":"问卷清单 - 思智树教师平台 - Google Chrome","app":"chrome"}]},{"x": 0, "y": 0, "width": 0, "height": 0},@res"0d166210-fccd-11ee-b3e3-139b772dd86b.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})
End IfNext
Mouse.Wheel(3,"down", [],{"iDelayAfter":300, "iDelayBefore":200})
#icon("@res:e3fa1e10-fd1e-11ee-a58c-e91e97990db1.png")
Image.Click({"wnd":[{"cls":"Chrome_WidgetWin_1","title":"问卷清单 - 思智树教师平台 - Google Chrome","app":"chrome"}]},{"x": 0, "y": 0, "width": 0, "height": 0},@res"e3fa1e10-fd1e-11ee-a58c-e91e97990db1.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(5000)Keyboard.Press("R", "press", ["Ctrl"],{"iDelayAfter": 300, "iDelayBefore": 200, "sSimulate": "simulate"})Delay(5000)Mouse.Move(1912, 600, false,{"iDelayAfter": 300, "iDelayBefore": 200})
Mouse.Click("left", "click", [],{"iDelayAfter": 300, "iDelayBefore": 300})
Mouse.Wheel(5,"down", [],{"iDelayAfter":300, "iDelayBefore":200})Mouse.Move(1422, 650, false,{"iDelayAfter": 300, "iDelayBefore": 200})
Mouse.Click("left", "click", [],{"iDelayAfter": 300, "iDelayBefore": 300})
iRet = Dialog.MsgBox("手动","Laiye Automation",0,1,0)
Next
Excel.CloseExcel(objExcelWorkBook,true)
视频展示:
一、PATHS情绪课程问卷(四人答题,自动点选选项,手动切换学号)
20240419UIBOT填写问卷(四人答题时间)
一份问卷(64题)与一份问卷(64题)之间有暂停按钮,便于人工选择下一份未完成的蓝色文字,打开问卷页面,便于程序自动填写
二、PATHS情绪课程问卷(单人答题时间)64题
20240419UIBOT填写情绪问卷(单人答题时间)
说明:
1、时间上看,做一份64题大约需要4分钟,30人就是2小时。并不比人工点击快多少。
2、效率上看,程序自动点击,不会点错,在自动选择答案时并在填完后暂停,操作者可以再此期间做些其他工作。无论多久,再回来看时,页面都保持暂停状态。
3、不足之处:问卷与问卷之间需要手动切换,人力还是被圈在电脑前。但总比人工不断动脑、再无数次点击选项要省力一点。
特别说明:
第一次运行(中4班)时,最后报错,数组超过限制。
问其他班级老师要了班级名单,再测试了一次