|
仅支持按键8.0语法的前台转后台辅助脚本(7.x语法如何升级为8.x?用导入,它就自动升级啦!)本版本的语法原型为 按键精灵 8.005993 版,不支持7.x的转换 本版本支持模糊 颜色判断,可以自行定义获得 窗口句柄的方法,储存窗口句柄的 变量名。 如果有任何Bug,欢迎反馈,建议使用QQ(见签名) 因为经常更新,所以请大家常来这个帖子看看有没有什么更新
- 参数小解
- 需要转换的文件的所在路径?:就是你需要转换哪个脚本,就请把他的路径写进去
- 转换后的文件输出到哪?:转换后,脚本将输出一个转换后的脚本,你想把它放在哪里,就填写那里的路径
- 使用什么方式获取句柄?:有三个选择,这里推荐使用“得到鼠标指向的窗口”
- 查找的窗口名:只有使用“查找窗口标题”的方式来获取句柄时才起作用,填入你想查找的窗口标题,没有填0
- 查找的窗口类名:只有使用“查找窗口标题”的方式来获取句柄时才起作用,填入你想查找的窗口类名,没有填0
- 以下两个默认即可,无需更改。
第一个鼠标动作必须是MoveTo 请在需转换的脚本中尽量不使用下划线结尾的变量,因为那是转换需要的。 该文件会在需转换文件尾写入字符串“//ISTHEEND”,这样可以使脚本兼容所以字符串(不像7.x中脚本不能有“|”字符)。 模糊颜色判断默认值为90%相似度即可。
这个是测试版,欢迎大家提出Bug!当然,也欢迎您对源码进行修改,以满足您的需要。
注:脚本无论如何强大至极,也不可能完全替代人工,某些时候还是要您自己动手干的,切记。。。切记。。。。
源码:
- UserVar 待转换文件路径="D:\需要转换的脚本.Q" "需要转换的文件的所在路径?"
- UserVar 已转换文件路径="D:\已经转换过的脚本.Q" "转换后的文件输出到哪?"
- UserVar GetHwnd=DropList{"得到鼠标指向的窗口":3|"查找窗口标题":1|"得到当前窗口":2}=3 "使用什么方式获取句柄?"
- UserVar Title="0" "查找的窗口名(仅在选择查找窗口标题时有效,没有填0)"
- UserVar Clas="0" "查找的窗口类名(仅在选择查找窗口标题时有效,没有填0)"
- UserVar Hwnd="Hwnd" "句柄储存到什么变量里?(默认即可)"
- UserVar Bl=DropList{"默认":0|"自定义":1}=0 "模糊颜色算法字符串是否默认(如果不了解,默认即可,非默认,请将算法字符串写入剪贴板后启动该脚本)"
- UserVar 原x=0 "原脚本制作时的窗口左上角的x坐标"
- UserVar 原y=0 "原脚本制作时的窗口左上角的y坐标"
- If Bl = 1 Then
- Col_ = Plugin.Sys.GetCLB()
- Else
- Col_ = CStr("Int(" & Chr(34) & "&h" & Chr(34) & " & Mid(Col_,1,2)) + Int(" & Chr(34) & "&h" & Chr(34) & " & Mid(Col_,3,2)) + Int(" & Chr(34) & "&h" & Chr(34) & " & Mid(Col_,5,2)) < (Int(" & Chr(34) & "&h" & Chr(34) & " & Mid(_C,1,2)) + Int(" & Chr(34) & "&h" & Chr(34) & " & Mid(_C,3,2)) + Int(" & Chr(34) & "&h" & Chr(34) & " & Mid(_C,5,2))) * 1.1 And Int(" & Chr(34) & "&h" & Chr(34) & " & Mid(Col_,1,2)) + Int(" & Chr(34) & "&h" & Chr(34) & " & Mid(Col_,3,2)) + Int(" & Chr(34) & "&h" & Chr(34) & " & Mid(Col_,5,2)) > (Int(" & Chr(34) & "&h" & Chr(34) & " & Mid(_C,1,2)) + Int(" & Chr(34) & "&h" & Chr(34) & " & Mid(_C,3,2)) + Int(" & Chr(34) & "&h" & Chr(34) & " & Mid(_C,5,2))) * 0.9")
- End If
- Dim 读取内容
- If Plugin.File.ExistFile(已转换文件路径) Then
- Call Plugin.File.DeleteFile(已转换文件路径)
- End If
- Call Plugin.File.WriteFileEx(已转换文件路径,"")
- Call Plugin.File.WriteFileEx(待转换文件路径,"//ISTHEEND")
- 待转换文件 = Plugin.File.OpenFile(待转换文件路径)
- 已转换文件 = Plugin.File.OpenFile(已转换文件路径)
- 内容2 = Plugin.File.ReadLine(待转换文件)
- While InStr(内容2,"//ISTHEEND") = 0
- 内容 = Trim(内容2)
- 内容 = Replace(内容," ","")
- 内容 = Replace(内容,Chr(13),"")
- 内容 = Replace(内容,Chr(10),"")
- 左6字符 = LCase(Left(内容,6))
- Select Case 左6字符
- Case "keypre"
- xy = Split(内容,"s "):xyArr = Split(xy(1),","):x = xyArr(0):y = xyArr(1)
- For y
- Call Plugin.File.WriteLine(已转换文件,"Call Plugin.Bkgnd.KeyPress(" & Hwnd & "," & x & ")")
- Next
- Case "keydow"
- xy = Split(内容,"n "):xyArr = Split(xy(1),","):x = xyArr(0):y = xyArr(1)
- For y
- Call Plugin.File.WriteLine(已转换文件,"Call Plugin.Bkgnd.KeyDown(" & Hwnd & "," & x & ")")
- Next
- Case "keyup "
- xy = Split(内容,"p "):xyArr = Split(xy(1),","):x = xyArr(0):y = xyArr(1)
- For y
- Call Plugin.File.WriteLine(已转换文件,"Call Plugin.Bkgnd.KeyUp(" & Hwnd & "," & x & ")")
- Next
- Case "leftcl"
- xy = Split(内容,"k ")
- For xy(1)
- Call Plugin.File.WriteLine(已转换文件,"Call Plugin.Bkgnd.LeftClick(" & Hwnd & "," & xs & " - xs_," & ys & " - ys_)")
- Next
- Case "leftdo"
- If LCase(Mid(内容,7,1)) = "u" Then
- xy = Split(内容,"k ")
- For xy(1)
- Call Plugin.File.WriteLine(已转换文件,"Call Plugin.Bkgnd.LeftDoubleClick(" & Hwnd & "," & xs & " - xs_," & ys & " - ys_)")
- Next
- Else
- xy = Split(内容,"n ")
- For xy(1)
- Call Plugin.File.WriteLine(已转换文件,"Call Plugin.Bkgnd.LeftDown(" & Hwnd & "," & xs & " - xs_," & ys & " - ys_)")
- Next
- End If
- Case "leftup"
- xy = Split(内容,"p ")
- For xy(1)
- Call Plugin.File.WriteLine(已转换文件,"Call Plugin.Bkgnd.LeftUp(" & Hwnd & "," & xs & " - xs_," & ys & " - ys_)")
- Next
- Case "rightc"
- xy = Split(内容,"k ")
- For xy(1)
- Call Plugin.File.WriteLine(已转换文件,"Call Plugin.Bkgnd.RightClick(" & Hwnd & "," & xs & " - xs_," & ys & " - ys_)")
- Next
- Case "rightd"
- xy = Split(内容,"n ")
- For xy(1)
- Call Plugin.File.WriteLine(已转换文件,"Call Plugin.Bkgnd.RightDown(" & Hwnd & "," & xs & " - xs_," & ys & " - ys_)")
- Next
- Case "rightu"
- xy = Split(内容,"p ")
- For xy(1)
- Call Plugin.File.WriteLine(已转换文件,"Call Plugin.Bkgnd.RightUp(" & Hwnd & "," & xs & " - xs_," & ys & " - ys_)")
- Next
- Case "middle"
- xy = Split(内容,"k ")
- For xy(1)
- Call Plugin.File.WriteLine(已转换文件,"Call Plugin.Bkgnd.MiddleClick(" & Hwnd & "," & xs & " - xs_," & ys & " - ys_)")
- Next
- Case "moveto"
- xy = Split(内容,"o "):xyArr = Split(xy(1),","):xs = xyArr(0):ys = xyArr(1)
- Call Plugin.File.WriteLine(已转换文件,"//*******************" & 内容 & ":脚本仅记下移动坐标,但并不写出移动语句,那是无意义的")
- Case "mover "
- xy = Split(内容,"R "):xyArr = Split(xy(1),","):xs = xs + xyArr(0):ys = ys + xyArr(1)
- Call Plugin.File.WriteLine(已转换文件,"//******************" & 内容 & ":脚本仅记下移动坐标,但并不写出移动语句,那是无意义的")
- Case "mousew"
- Call Plugin.File.WriteLine(已转换文件,"//" & 内容 & "系统不知道该如何处置此语句")
- Case "savemo"
- xss = xs:yss = ys
- Case "redtor"
- xs = xss:ys = yss
- Case "lockmo"
- Call Plugin.File.WriteLine(已转换文件,"//********************" & 内容 & "系统不知道该如何处置此语句")
- Case "unlock"
- Call Plugin.File.WriteLine(已转换文件,"//********************" & 内容 & "系统不知道该如何处置此语句")
- Case "getcur"
- If Mid(内容,10,1) = "p" Then
- xy = Split(内容,"s "):xyArr = Split(xy(1),","):x = xyArr(0):y = xyArr(1)
-
- Call Plugin.File.WriteLine(已转换文件,xyArr(0) & " = " & xs & ":" & xyArr(1) & " = " & ys)
- Else
- Call Plugin.File.WriteLine(已转换文件,"//********************" & 内容 & "系统不知道该如何处置此语句")
- End If
- Case "ifcolo"
- xy = Split(内容,"r "):xyArr = Split(xy(1),",")
- Call Plugin.File.WriteLine(已转换文件,"Col_ = Plugin.BkgndColor.GetPixelColor(" & Hwnd & "," & xyArr(0) & " - xs_," & xyArr(1) & " - ys_)")
- Select Case xyArr(3)
- Case 0
- Call Plugin.File.WriteLine(已转换文件,"If Col_ = " & xyArr(2) & " Then")
- Case 1
- Call Plugin.File.WriteLine(已转换文件,"If Col_ <> " & xyArr(2) & " Then")
- Case 2
- Col_ = Replace(Col_,"_C", xyArr(2))
- Call Plugin.File.WriteLine(已转换文件,"If " & Col_ & " Then")
- End Select
- Case "findco"
- xy = Split(内容,"r "):xyArr = Split(xy,",")
- If Mid(内容,10,1) = "e" Then
- Call Plugin.File.WriteLine(已转换文件,"_XY = Plugin.Bkgnd.FindColor(" & Hwnd & "," & xyArr(0) & " - xs_," & xyArr(1) & " - ys_," & xyArr(2) & " - xs_," & xyArr(3) & " - ys_," & Chr(34) & xyArr(4) & Chr(34) & "," & xyArr(5) & "," & xyArr(6) & ")")
- Call Plugin.File.WriteLine(已转换文件,"_XY = Split(_XY," & Chr(34) & "|" & Chr(34) & "):" & xyArr(7) & " = _XY(0)" & ":" & xyArr(8) & " = _XY(1)")
- Else
- Call Plugin.File.WriteLine(已转换文件,"_XY = Plugin.Bkgnd.FindColor(" & Hwnd & "," & xyArr(0) & " - xs_," & xyArr(1) & " - ys_," & xyArr(2) & " - xs_," & xyArr(3) & " - ys_," & Chr(34) & xyArr(4) & Chr(34) & ")")
- Call Plugin.File.WriteLine(已转换文件,"_XY = Split(_XY," & Chr(34) & "|" & Chr(34) & "):" & xyArr(5) & " = _XY(0)" & ":" & xyArr(6) & " = _XY(1)")
- EndIf
- Case "findce"
- xy = Split(内容,"r "):xyArr = Split(xy,",")
- Call Plugin.File.WriteLine(已转换文件,"_XY = Plugin.Bkgnd.FindColor(" & Hwnd & " - xs_," & xyArr(0) & " - ys_," & xyArr(1) & " - xs_," & xyArr(2) & " - ys_," & xyArr(3) & "," & Chr(34) & xyArr(4) & Chr(34) & ")")
- Call Plugin.File.WriteLine(已转换文件,"_XY = Split(_XY," & Chr(34) & "|" & Chr(34) & "):" & xyArr(5) & " = _XY(0)" & ":" & xyArr(6) & " = _XY(1)")
- Case "findpi"
- Call Plugin.File.WriteLine(已转换文件,"//**************************" & 内容 & "系统不知道该如何处置此语句,后台并不支持找图")
- Case "[scrip"
- Call Plugin.File.WriteLine(已转换文件,内容)
- Select Case GetHwnd
- Case 1
- Call Plugin.File.WriteLine(已转换文件,Hwnd & " = " & "Plugin.Window.Find(" & Chr(34) & Clas & Chr(34) & "," & Chr(34) & Title & Chr(34) & ")")
- Case 2
- Call Plugin.File.WriteLine(已转换文件,Hwnd & " = " & "Plugin.Window.Foreground() ")
- Case 3
- Call Plugin.File.WriteLine(已转换文件,Hwnd & " = " & "Plugin.Window.MousePoint()")
- End Select
- Call Plugin.File.WriteLine(已转换文件,"xs_ = " & 原x & ":ys_ = " & 原y)
- Case Else
- If InStr(内容,"findpixecolor") Then
- tem = Split(内容,"=")
- xy = Split(Trim(tem(1))," ")
- xyArr = Split(xy,",")
- Call Plugin.File.WriteLine(已转换文件,tem & " = " & "Plugin.BkgndColor.GetPixelColor(" & Hwnd & "," & xyArr(0) & " - xs_," & xyArr(1) & " - ys_)")
- Else
- Call Plugin.File.WriteLine(已转换文件,内容)
- End If
- End Select
- 内容2 = Plugin.File.ReadLine(待转换文件)
- WEnd
- EndScript
- Sub OnScriptExit
- Call Plugin.File.CloseFile(待转换文件)
- Call Plugin.File.CloseFile(已转换文件)
- Msgbox "转换完毕"
- End Sub
更新日志: 已知但尚不可改正的Bug:当附件过大时按键精灵自动关闭的Bug 临时解决方法:将脚本源文件(*.Q文件)中的 [Attachment] 一项即其所述内容剪切出来,转换后剪切回去。
|