Import "GK.luae"
If GK.Find("378|583|0FBA06,373|611|292EDF,343|609|DA9D08",true) then
TracePrint "找到对象并点击"
End If
If GK.Find("378|583|0FBA06,373|611|292EDF,343|609|DA9D08") then
TracePrint "找到对象无点击"
End If
Dim A={"378|583|0FBA06,373|611|292EDF,343|609|DA9D08"}
TracePrint GK.Find(A)
Import "GK.luae"
dim a=GK.Find2("378|583|0FBA06,373|611|292EDF,343|609|DA9D08")
TracePrint a(0),a(1),a(2)
Dim B={"378|583|0FBA06,373|611|292EDF,343|609|DA9D08"}
Dim arr=GK.Find2(B)
TracePrint arr(0),arr(1),arr(2)
Dim arr_=GK.Find2({"378|583|0FBA06,373|611|292EDF,343|609|DA9D08"})
TracePrint arr_(0),arr_(1),arr_(2)
Import "GK.luae"
If GK.Find(311,489,409,580,"0FBA06","-5|28|292EDF,-35|26|DA9D08") then
TracePrint "click"
End If
Dim A={"0FBA06","-5|28|292EDF,-35|26|DA9D08",0.8}
TracePrint GK.Find(A)
TracePrint GK.Find({"0FBA06","-5|28|292EDF,-35|26|DA9D08",0.8})
Import "GK.luae"
dim a=GK.Find2(311,489,409,580,"0FBA06","-5|28|292EDF,-35|26|DA9D08")
TracePrint a(0),a(1),a(2)
Dim B={"0FBA06","-5|28|292EDF,-35|26|DA9D08",false}
Dim arr=GK.Find2(B)
TracePrint arr(0),arr(1),arr(2)
Dim arr_=GK.Find2({"0FBA06","-5|28|292EDF,-35|26|DA9D08",false})
TracePrint arr_(0),arr_(1),arr_(2)
Import "GK.luae"
If Gk.Find("图片.png") then
TracePrint "找到对象"
End If
If Gk.Find(311,489,409,580,"图片.png",true) then
TracePrint "找到对象并点击"
End If
Dim A={"图片1.png|图片2.png","303030",1,0.8}
TracePrint GK.Find(A)
Import "GK.luae"
Dim a=GK.Find2(311,489,409,580,"图片.png")
TracePrint a(0),a(1),a(2),a(3)
Dim B={311,489,409,580,"图片1.png|图片2.png"}
Dim arr=GK.Find2(B)
TracePrint arr(0),arr(1),arr(2),arr(3)
Dim arr_=GK.Find2({311,489,409,580,"图片1.png|图片2.png"})
TracePrint arr_(0),arr_(1),arr_(2),arr_(3)
Import "GK.luae"
If GK.Find(311,489,409,580,"0FBA06",0.999) then
TracePrint "click"
End If
Dim A={"0FBA06|845C1B",0.999,false}
TracePrint GK.Find(A)
TracePrint GK.Find({"0FBA06|845C1B",0.999})
Import "GK.luae"
Dim a=GK.Find2(311,489,409,580,"0FBA06|292EDF|DA9D08",0.999)
TracePrint a(0),a(1),a(2)
Dim B={"0FBA06|292EDF|DA9D08",0.999,2}
Dim arr=GK.Find2(B)
TracePrint arr(0),arr(1),arr(2)
Dim arr_=GK.Find2({"0FBA06|292EDF|DA9D08",0.999,2})
TracePrint arr_(0),arr_(1),arr_(2)
Import "GK.luae"
If GK.Find(378,583,"0FBA06",0.999) then
TracePrint "true"
End If
Dim A={378,583,"0FBA06|845C1B",0.999}
TracePrint GK.Find(A)
TracePrint GK.Find({378,583,"0FBA06|845C1B",0.999})
Import "GK.luae"
Dim a=GK.Find2(378,583,"0FBA06",0.999)
TracePrint a
Dim B={378,583,"0FBA06|845C1B",0.999}
TracePrint GK.Find2(B)
TracePrint GK.Find2({378,583,"0FBA06|845C1B",0.999})
If GK.RPA("resource-id", "com.tencent.android.qqdownloader:id/pt", 156, 186, 204, 234, true) Then
TracePrint "激活元素对象:通过匹配对象元素resource-id属性和元素对象形状(范围坐标)的方式。"
End If
[GK.RPA 代码示例3]:仅通过匹配元素对象的形状来激活对象
Dim Table={"","",430, 366, 570, 540,true,2}
If GK.RPA(Table) Then
TracePrint "激活元素对象:仅通过匹配元素对象形状(范围坐标)的方式,且参数以表的形式传递。"
End If
[GK.RPA 代码示例4]:模糊匹配包含指定text关键字的元素标题。
dim table = GK.RPA("text", "下载", 1)
If table Then
TracePrint "模糊匹配查找包含“下载”的元素标题,已找到下载按钮"&Len(table)&"个。"
For i = 1 To Len(table)
For Each k , v In table[i]
TracePrint k,v
Next
Next
End If
Dim Table,RetTable,ET1={"text","神武4"},ET2={"class","android.widget.TextView"}
Table=GK.RPA()
RetTable = gk.RPA_Lookup(Table, ET1, ET2)
If RetTable Then
For Each k , v In RetTable
NextTracePrint k, v
Next
End If
[RPA_Lookup 代码示例2]:单独匹配一组元素属性,且采用模糊匹配方式
Dim RetTable,Table=GK.RPA()
RetTable = gk.RPA_Lookup(Table,{"text","神武"},1)
If RetTable Then
For Each k , v In RetTable
TracePrint k,v
Next
End If
Dim Ret,t,ET() //ET数组存入用于匹配元素对象的resource-id属性数据
ET(0)="com.achievo.vipshop:id/rebate_name" //商品名称
ET(1)="com.achievo.vipshop:id/product_item_sale_price" //商品价格
Dim Table = GK.RPA("resource-id", "com.achievo.vipshop:id/product_list_recycler_view") //根据resource-id查找商品页面共同的父节点(找父亲)。
If Table Then
For i = 1 To Len(Table[1]["children"]) //遍历每一个包含商品信息项的子节点(找儿子)。
For t = 1 To Len(ET)
Ret= GK.RPA_Lookup(Table[1]["children"][i],{"resource-id",ET[t]}) //通过resource-id(由ET数组变量传递)匹配对应的商品名称和商品价格。
If Ret Then
TracePrint Ret["text"] //找到商品名称或商品价格后,将其text属性值输出。
End If
Next
Next
End If
Dim table=GK.RPA()
For i = 1 To Len(table)
If table[i]["text"] = "京东特价商品" Then
dim text = GK.RPA_Track("resource-id", "com.tencent.android.qqdownloader:id/awy",i)
TracePrint "特价商品"&i&":"&text
End If
Next
Dim 商品信息()
For 2
商品信息["商品名称"] = "杜蕾斯"
商品信息["商品价格"] = "¥18"
商品信息["商品折扣"] = "8.8折"
If gk.RPA_Check(商品信息) Then
TracePrint "商品信息检查通过,未出现重复数据。"
Else
TracePrint "商品信息检查未通过,出现重复数据。"
End If
Next
[RPA_Check 代码示例2]:以传入多个普通变量的方式检查重复商品
Dim 商品名称="杜蕾斯",商品价格 = "¥18",商品折扣 = "8.8折"
For 2
If gk.RPA_Check(商品名称, 商品价格, 商品折扣) Then
TracePrint "商品信息检查通过,未出现重复数据。"
Else
TracePrint "商品信息检查未通过,出现重复数据。"
End If
Next
dim table = gk.RPA_Find("android.widget.TextView","微信")
If table Then
TracePrint "果壳式Find查找指定元素属性(类名+标题),共"&Len(table)&"个"
For i = 1 To Len(table)
For Each k , v In table[i]
TracePrint k,v
Next
Next
End If
[RPA_Find 代码示例2]:通过元素标题属性(text)查找微信图标
dim table = GK.RPA_Find("微信")
TracePrint "果壳式Find查找指定元素属性(标题),共"&Len(table)&"个"
dim table = GK.RPA_GetAll()
If table Then
TracePrint "果壳式GetAll获取元素属性,共"&Len(table)&"个"
For i = 1 To Len(table)
For Each k , v In table[i]
TracePrint k,v
Next
Next
End If
dim table = GK.RPA_GetFull()
If table Then
TracePrint "果壳式GetFull获取元素属性,共"&Len(table)&"个"
For i = 1 To Len(table)
For Each k , v In table[i]
TracePrint k,v
Next
Next
End If
24RPA获取元素标题
[获取所有元素标题] 函数原型:
GK.RPA_GetText()
获取当前界面的所有元素标题:text属性
[参数说明]:
无参数
[返回值说明]:
返回一个表,表中包含所有元素的text属性。
[RPA_GetText 代码示例]:
dim table = GK.RPA_GetText()
If table Then
TracePrint "果壳式GetText获取所有元素标题,共"&Len(table)&"个"
For Each k , v In table
TracePrint k,v
Next
End If
25RPA点击元素中心
[点击元素对象中心] 函数原型:
GK.RPA_Click(tUI)
点击范围坐标所确定的元素对象的中心点。
[参数说明]:
tUI参数代表某一元素对象的元素表。
[返回值说明]:
无返回值。
[RPA_Click 代码示例]:抓取元素对象微信图标的范围坐标数据,并点击该对象中心点
dim table = gk.RPA("text", "微信")
If table Then
gk.RPA_Click(table[1])
End If