---------------调用自己的函数(把通用文件导入项目,就可以直接使用函数)---------------
my.mylog(file_log,"获取表格一行" & arrRet[2] )
---------------钉钉消息通知--------------------
Dim content="机器人:LX01打印收款回单完成"
Dim url = "https://oapi.dingtalk.com/robot/send?access_token=ea1e21d3528532597ec7f03a981879ca2582cfe2de0ce6e6989463128caa9b11"
HTTP.PostJson( url &"&Content-Type=application/json", {"msgtype": "text","text": {"content": content}}, 60000)
---------------不同服务器,执行不同的功能--------------------
// 测试
bRet_NC_FLAG = File.FileExists("E:\\RPA服务器标志TEST.txt")
If bRet_NC_FLAG = True
iPID = App.Run("C:\\Users\\adm1\\Downloads\\UClient.exe", "0", "1")
End If
// 正式
bRet_NC_FLAG2 = File.FileExists("E:\\RPA服务器标志PRD.txt")
If bRet_NC_FLAG2 = True
iPID = App.Run("C:\\Users\\Administrator\\Desktop\\UClient.exe", "0", "1")
End If
---------------INI文件读取---------------------
// -----读INI文件----------------
Dim file_config = "E:\\XXX运行结果\\LX07NC与SAP对账7\\config.ini"
ini_year = INI.Read(file_config, "zinput", "year", "")
ini_month = INI.Read(file_config, "zinput", "month", "")
---------------excel读取到数组后,数组增加列---------------------
很奇特的功能,只在数组某一行增加了一个字段,数组的其它行字段和更改的行并不对齐。
array[0] 4个字段,
array[1] 5个字段,
array[2] 4个字段
---------------excel读取---------------------
// 1、打开excel
objExcelWorkBook = Excel.OpenExcel("E:\\NC凭证清单表.xlsx",True,"Excel","","")
// 2、读取内容
arrayRet = Excel.ReadRange(objExcelWorkBook,"Sheet2","A2:D25")
//3、关闭excel
Excel.CloseExcel(objExcelWorkBook,true)
//4、输出内容
TracePrint arrayRet
打印内存中的arrayRet变量如下:(可以看到是一个二维数组)
TracePrint arrayRet [1]
打印内存中的arrayRet[1]变量如下:(二维数组的第一行)
TracePrint arrayRet [1][1]
打印内存中的arrayRet[1][1]变量如下:(二维数组的第一行,第一列)
---------------处理excel中每一行的数据----------------------
For Each one In arrayRet
TracePrint one
Next
---------------文本文件的使用---------------------
每一个数据放一行,读取后拆分到数组中,依次打印出来,注意最后有一个空行
Dim filepath = "E:\\打印日志5.txt"
File.Append(filepath,"1\n","gbk")
File.Append(filepath,"2\n","gbk")
File.Append(filepath,"3\n","gbk")
sRet = File.Read(filepath,"auto")
arrRet = Split(sRet,"\n")
//数组个数
TracePrint( "数组个数:"& Len(arrRet ) )
//显示每一个,字符串为0不显示
For Each one In arrRet
If Len(one) > 0
TracePrint("item:"&one)
End If
Next
---------------检测窗口---------------------
// ----窗口如果消失,程序继续执行--[条件成立,继续循环]-
Function wait_win_dis(handle)
Do
Delay(2000)
Loop While Window.Exists(handle)
End Function
// ----程序一直等待窗口出现--[条件成立,退出循环]--
Function wait_win(handle)
Do
Delay(1000)
Loop Until Window.Exists(handle)
End Function
---------------写log日志文件---------------------
// ----log文件----
Function mylog(file_log,str)
Dim dTime = ""
Dim ztime = ""
dTime = Time.Now()
ztime = Time.Format(dTime,"yyyy-mm-dd hh:mm:ss")
File.Append(file_log, "[" & ztime & "]" & str &"\n","gbk")
End Function
---------------一行登陆SAP并打开事务代码---------------------
//快捷登陆SAP
sRet = Sys.Command("start sapshcut -sid=DEV -clt=800 -u=刘欣 -pw=密码 -guiparm=/H/10.18.xxx.xxx/S/3200 -language=ZH -command=zfir0003 -max ,0,false")
-------------执行批处理脚本,脚本设置当前目录为环境变量路径---------------------
//执行插件
iPID = App.Run("E:\\XXXX运行结果\\LX07NC与SAP对账7\\go.bat", "0", "1")
go.bat内容如下:
cd /d "E:\xxxx运行结果\LX07NC与SAP对账7"
"Light.exe"
---------------图像写屏幕,输出信息---------------------
// 全家变量
g_screen = PrintToScreen.CreateWindow({"x":1200,"y":100,"width":800,"height":900,"resolution":{"width":1920,"height":1080}},True)
PrintToScreen.DrawText(g_screen,Time.Format(Time.Now(),"yyyy-mm-dd hh:mm:ss") & " 登陆NC开始",36,[255,0,0])
PrintToScreen.DrawText(g_screen,Time.Format(Time.Now(),"yyyy-mm-dd hh:mm:ss") & " 登陆SAP执行",36,[255,0,0])