[按键精灵] 纯文本查看 复制代码
Dim DBpath
DBpath = "C:\滑动数据库测试6.mdb"
Call WriteBackPic("沙漠", 100, 100, 10)
'根据不同的滑块,设置间距,间距x或间距y要有一个为1,后面获取数据才会精确
Call WriteColor("沙漠", 100, 100, 120, 180, 1, 40)
Function WriteBackPic(图片名,起点x,起点y,取点个数) '写入背景图身份特征,取点为图片不会变化的地方
Dim DBIndex,arr,TBIndex,Data,SqlStr,i,Value
DBIndex = Plugin.LazyOffice.AccDBOpen(DBpath) '打开一个数据库文件,没有此数据库则新建一个
arr = Plugin.LazyOffice.AccListTBs(DBIndex)
If InStr(Join(arr, ","), "集合表") = 0 Then
'创建一个表名(集合表),字段名"ID",字段名"picdatas",字段名"TPName",并设置各字段属性
SqlStr = "Create TABLE [集合表]([ID] COUNTER NOT NULL, [picdatas] char,[TPName] char)"
TracePrint Plugin.LazyOffice.AccDBRun(SqlStr,DBIndex)
End If
TBIndex = Plugin.LazyOffice.AccTBOpen("集合表", DBIndex,"*","") '打开表名("集合表")的数据表
For i = 起点x To 起点x + 取点个数 - 1
If Data = "" Then
Data = i & "," & 起点y & "|" & GetPixelColor(i, 起点y)
Else
Data = Data & "," & i & "," & 起点y & "|" & GetPixelColor(i, 起点y)
End If
Next
Value = Plugin.LazyOffice.AccTBGetPosi(TBindex, DBindex)
Value = Plugin.LazyOffice.AccTBMovePosi("Last", TBindex, DBindex)
Value = Plugin.LazyOffice.AccTBAddRecord(TBindex, DBindex)
arr = Array("",Data,图片名)
Value = Plugin.LazyOffice.AccTBSetValueArrR(arr, TBindex, DBindex) '修改数据表当前行所有数据
If Value > 0 Then
TracePrint "写入成功"
Else
TracePrint "写入失败"
End If
Call 关闭数据库(DBIndex,TBindex)
End Function
Function WriteColor(图片名, 起点x, 起点y, 终点x, 终点y, x间距, y间距) '写入图片颜色到数据库(在没有滑块挡住的部分)
Dim DBIndex,arr,TBIndex
DBIndex = Plugin.LazyOffice.AccDBOpen(DBpath) '打开一个数据库文件,没有此数据库则新建一个
arr = Plugin.LazyOffice.AccListTBs(DBIndex)
If InStr(Join(arr, ","), 图片名) = 0 Then
'创建一个表名(图片名),字段名"ID",字段名"picdata",并设置各字段属性
SqlStr = "Create TABLE ["& 图片名 &"]([ID] COUNTER NOT NULL, [picdata] char)"
TracePrint Plugin.LazyOffice.AccDBRun(SqlStr,DBIndex)
End If
TBIndex = Plugin.LazyOffice.AccTBOpen(图片名, DBIndex,"picdata","") '打开表名(图片名)的数据表
TracePrint TBIndex
For y = 起点y To 终点y Step y间距
For x = 起点x To 终点x Step x间距
Value = Plugin.LazyOffice.AccTBGetPosi(TBindex, DBindex)
Value = Plugin.LazyOffice.AccTBMovePosi("Last", TBindex, DBindex)
Value = Plugin.LazyOffice.AccTBAddRecord(TBindex, DBindex) '数据表增加一行数据
arr = Array(x & "," & y & "|" & GetPixelColor(x, y))
Value = Plugin.LazyOffice.AccTBSetValueArrR(arr, TBindex, DBindex) '修改数据表当前行所有数据
Next
Next
If Value > 0 Then
TracePrint "写入成功"
Else
TracePrint "写入失败"
End If
Call 关闭数据库(DBIndex,TBindex)
End Function
Sub 关闭数据库(DBIndex,TBindex)
Call Plugin.LazyOffice.AccDBClose(DBIndex)
Call Plugin.LazyOffice.AccTBClose(TBindex, DBIndex)
End Sub