uibot基础知识

基础命令

定义变量

    Dim a="UiBot"

数据类型转换

查看数据类型   type()   
例:TracePrint("转换前数据类型为:"&Type("1.5"))
    转整型         dRet = CInt(1.5)
    转小数         dRet = CNumber("1.5")
    转字符         dRet = CStr(1)
    延时           Delay(1000)              #1000毫秒 = 1秒
    例:        dTime = Time.Now()
                sRet = Time.Format(dTime,"yyyy-mm-dd")
                TracePrint("当前时间为:"&sRet)

子程序(方法)

    		Function test(a,b)
        		Return a+b
    		End Function
   		    TracePrint ("执行结果:"&test(1,2))

基础语法

条件分支

Select Case

    Select Case a + 1 
        Case 1
            TracePrint("This is Case 1")
        Case 2 
            TracePrint("This is Case 2")
        Case 3 
            TracePrint("This is Case 3")
        Case Else
            TracePrint("This is Case Else")
        End Select

IF

        If a = 1
            TracePrint "yes"
        ElseIf a = "UiBot"
            TracePrint "no"
        Else
            TracePrint "no0"
        End If

循环

DO LOOP 无限循环

        TracePrint("无限执行a加1计算")
            a = 1
            Do 
                a = a+1
            Loop

DO LOOP Until

先执行语句块 (Block),使用 Until 时,
当条件表达式 (expression) 的值为假(不成立)时则继续执行语句(Block),
当条件表达式 (expression) 的值为真(成立)时退出循环)

      TracePrint("令a=1,执行a自增1,直到a等于10,退出循环")
                a = 1
                Do 
                    a = a + 1
                Loop Until a=10

DO LOOP While

使用 While 时,执行 Block 语句块,当 expression 为真时退出循环

TracePrint("令a=1,令a自增1,此时a = 2,符合循环条件a=2,退出循环"
                a = 1
                Do 
                    a = a + 1
                    TracePrint a
                Loop While a = 2

For Each 遍历数组

            temp = [1,2,3,5,6]
            For Each value In temp
                TracePrint(value)
            Next

For Each 遍历字典

            t = {'name':'zhangsan','age':14 }
            For Each key, value In t
                TracePrint(key&' '&value)
            Next

For 步长遍历

            For i = 0 To 10 step 1
                TracePrint(i)
            Next

异常

普通异常执行
Try
Mouse.Action(@ui"","left","click",10,{"bContinueOnError": false, "iDelayAfter": 300, "iDelayBefore": 200, "bSetForeground": true, "sCursorPosition": "Center", "iCursorOffsetX": 0, "iCursorOffsetY": 0, "sKeyModifiers": [],"sSimulate": "simulate", "bMoveSmoothly": false})
Catch 变量名
TracePrint("出现异常")
End Try
TracePrint("后续程序")

重复执行多次
a = 0
Try 3 
a = a+1
Mouse.Action(@ui"","left","click",10,{"bContinueOnError": false, "iDelayAfter": 300, "iDelayBefore": 200, "bSetForeground": true, "sCursorPosition": "Center", "iCursorOffsetX": 0, "iCursorOffsetY": 0, "sKeyModifiers": [],"sSimulate": "simulate", "bMoveSmoothly": false})
Catch 变量名 
TracePrint("出现异常")
End Try
TracePrint(a)

日志

Log.SetLevel 设置日志级别共5类
在这里插入图片描述

设置日志级别
Log.SetLevel(3)
写入错误日志
Log.Error("111")
写入警告日志
Log.Warn("222")‘
写入调试日志
Log.Debug("333")
写入普通日志
Log.Info("444")
写入输出日志
TracePrint(a)
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值