随机延迟的临时替代办法

垦荒牛 9天前 90

临时替代品,两个参数,最大值和最小值,调用就可以了!

在某处新建Excel空文件,修改代码里面的路径,不可隐藏,测试几次隐藏无效!无效!无效!

缺点:随机范围越大,运行时间越长,随机1秒本身运行时间也要4到5秒,也就是说,随机1秒,实际的时间消耗是1秒+运行时间

就是一个思路,欢迎大家指正!

====================================================================================================

import uibot3757aff5da93b6
dim t = uibot3757aff5da93b6.随机数(5,10)
Delay T
TracePrint("延时了"&T/1000&"秒")

RPA,RPA机器人_随机延迟的临时替代办法

=====================================================================================================

Function 随机数(zx,zd)

dim sText = ""
dim sjs = ""
dim objExcelWorkBook = ""


objExcelWorkBook = Excel.WorkBookOpen("C:\\Users\\Administrator\\Desktop\\随机数2.xlsx","","",true)
For i = 1 To zd-zx+1 step 1

Excel.CellSetText(objExcelWorkBook,1,i,1,zx)
Excel.CellSetEval(objExcelWorkBook,1,i,2,"=RAND()")
zx = zx+1

Next

Delay(1000)
#icon("@res:mr1j0u9c-g9a1-1kev-qls3-1ta54u2p7qkk.png")
Mouse.Action({"wnd":[{"app":"EXCEL","cls":"XLMAIN","title":"Microsoft Excel - 随机数.xlsx"},{"cls":"EXCEL;"},{"cls":"ComboBox"},{"cls":"Edit","ctrlid":1001}]},"left","click",10000,{"bContinueOnError":false,"iDelayAfter":300,"iDelayBefore":200,"bSetForeground":true,"sCursorPosition":"Center","iCursorOffsetX":0,"iCursorOffsetY":0,"sKeyModifiers":[],"sSimulate":"simulate"})
Mouse.Click("left", "click", [])
Keyboard.Input("b1")
Keyboard.Press("Enter", "press", [])

Delay(1000)
Keyboard.Press("A", "press", ["Alt"])
Delay(1000)
Keyboard.Press("A", "press", [])
Delay(1000)

sText=Excel.CellGetText(objExcelWorkBook,1,1,1)
sjs = stext*1000

Excel.Close(objExcelWorkBook,true)


Return sjs

End Function



上传的附件:
最新回复 (3)
  • 李发财 9天前
    2
    @_@
  • MAKI 9天前
    3
    支持!
  • 哒哒 8天前
    4

    用 RND() 命令不好么?Rnd()取值范围是[0,1),包含0但不包含1

返回
发新帖