• 首页
  • 教程
  • 资源
  • 脚本
  • 源码库
  • 新闻
  • 卖脚本
  • 用户中心
加入收藏  返回官网
你的位置:按键精灵资源站 >> 知识库
仅支持按键8.0语法的前台后台辅助脚本(7.x语法如何升级为8.x?用导入,它就自动升级啦!)
本版本的语法原型为 按键精灵 8.005993 版,不支持7.x的转换
本版本支持模糊颜色判断,可以自行定义获得窗口句柄的方法,储存窗口句柄的变量名。

如果有任何Bug,欢迎反馈,建议使用QQ(见签名)

因为经常更新,所以请大家常来这个帖子看看有没有什么更新
  1. 参数小解
  2. 需要转换的文件的所在路径?:就是你需要转换哪个脚本,就请把他的路径写进去
  3. 转换后的文件输出到哪?:转换后,脚本将输出一个转换后的脚本,你想把它放在哪里,就填写那里的路径
  4. 使用什么方式获取句柄?:有三个选择,这里推荐使用“得到鼠标指向的窗口”
  5. 查找的窗口名:只有使用“查找窗口标题”的方式来获取句柄时才起作用,填入你想查找的窗口标题,没有填0
  6. 查找的窗口类名:只有使用“查找窗口标题”的方式来获取句柄时才起作用,填入你想查找的窗口类名,没有填0
  7. 以下两个默认即可,无需更改。

 

第一个鼠标动作必须是MoveTo
请在需转换的脚本中尽量不使用下划线结尾的变量,因为那是转换需要的。
该文件会在需转换文件尾写入字符串“//ISTHEEND”,这样可以使脚本兼容所以字符串(不像7.x中脚本不能有“|”字符)。
模糊颜色判断默认值为90%相似度即可。

这个是测试版,欢迎大家提出Bug!当然,也欢迎您对源码进行修改,以满足您的需要。

注:脚本无论如何强大至极,也不可能完全替代人工,某些时候还是要您自己动手干的,切记。。。切记。。。。


源码:

 

 

  1. UserVar 待转换文件路径="D:\需要转换的脚本.Q" "需要转换的文件的所在路径?"
  2. UserVar 已转换文件路径="D:\已经转换过的脚本.Q" "转换后的文件输出到哪?"
  3. UserVar GetHwnd=DropList{"得到鼠标指向的窗口":3|"查找窗口标题":1|"得到当前窗口":2}=3 "使用什么方式获取句柄?"
  4. UserVar Title="0" "查找的窗口名(仅在选择查找窗口标题时有效,没有填0)"
  5. UserVar Clas="0" "查找的窗口类名(仅在选择查找窗口标题时有效,没有填0)"
  6. UserVar Hwnd="Hwnd" "句柄储存到什么变量里?(默认即可)"
  7. UserVar Bl=DropList{"默认":0|"自定义":1}=0 "模糊颜色算法字符串是否默认(如果不了解,默认即可,非默认,请将算法字符串写入剪贴板后启动该脚本)"
  8. UserVar 原x=0 "原脚本制作时的窗口左上角的x坐标"
  9. UserVar 原y=0 "原脚本制作时的窗口左上角的y坐标"
  10. If Bl = 1 Then
  11.     Col_ = Plugin.Sys.GetCLB()
  12. Else
  13.     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")
  14. End If
  15. Dim 读取内容
  16. If Plugin.File.ExistFile(已转换文件路径) Then
  17.     Call Plugin.File.DeleteFile(已转换文件路径)
  18. End If
  19. Call Plugin.File.WriteFileEx(已转换文件路径,"")
  20. Call Plugin.File.WriteFileEx(待转换文件路径,"//ISTHEEND")
  21. 待转换文件 = Plugin.File.OpenFile(待转换文件路径)
  22. 已转换文件 = Plugin.File.OpenFile(已转换文件路径)
  23. 内容2 = Plugin.File.ReadLine(待转换文件)
  24. While InStr(内容2,"//ISTHEEND") = 0
  25.     内容 = Trim(内容2)
  26.     内容 = Replace(内容,"    ","")
  27.     内容 = Replace(内容,Chr(13),"")
  28.     内容 = Replace(内容,Chr(10),"")
  29.     左6字符 = LCase(Left(内容,6))
  30.     Select Case 左6字符
  31.     Case "keypre"
  32.         xy = Split(内容,"s "):xyArr = Split(xy(1),","):x = xyArr(0):y = xyArr(1)
  33.         For y
  34.             Call Plugin.File.WriteLine(已转换文件,"Call Plugin.Bkgnd.KeyPress(" & Hwnd & "," & x & ")")
  35.         Next
  36.     Case "keydow"
  37.         xy = Split(内容,"n "):xyArr = Split(xy(1),","):x = xyArr(0):y = xyArr(1)
  38.         For y
  39.             Call Plugin.File.WriteLine(已转换文件,"Call Plugin.Bkgnd.KeyDown(" & Hwnd & "," & x & ")")
  40.         Next
  41.     Case "keyup "
  42.         xy = Split(内容,"p "):xyArr = Split(xy(1),","):x = xyArr(0):y = xyArr(1)
  43.         For y
  44.             Call Plugin.File.WriteLine(已转换文件,"Call Plugin.Bkgnd.KeyUp(" & Hwnd & "," & x & ")")
  45.         Next
  46.     Case "leftcl"
  47.         xy = Split(内容,"k ")
  48.         For xy(1)
  49.             Call Plugin.File.WriteLine(已转换文件,"Call Plugin.Bkgnd.LeftClick(" & Hwnd & "," & xs & " - xs_," & ys & " - ys_)")
  50.         Next
  51.     Case "leftdo"
  52.     If LCase(Mid(内容,7,1)) = "u" Then
  53.     xy = Split(内容,"k ")
  54.         For xy(1)
  55.             Call Plugin.File.WriteLine(已转换文件,"Call Plugin.Bkgnd.LeftDoubleClick(" & Hwnd & "," & xs & " - xs_," & ys & " - ys_)")
  56.         Next
  57.     Else
  58.     xy = Split(内容,"n ")
  59.         For xy(1)
  60.             Call Plugin.File.WriteLine(已转换文件,"Call Plugin.Bkgnd.LeftDown(" & Hwnd & "," & xs & " - xs_," & ys & " - ys_)")
  61.         Next
  62.     End If
  63.     Case "leftup"
  64.         xy = Split(内容,"p ")
  65.         For xy(1)
  66.             Call Plugin.File.WriteLine(已转换文件,"Call Plugin.Bkgnd.LeftUp(" & Hwnd & "," & xs & " - xs_," & ys & " - ys_)")
  67.         Next
  68.     Case "rightc"
  69.         xy = Split(内容,"k ")
  70.         For xy(1)
  71.             Call Plugin.File.WriteLine(已转换文件,"Call Plugin.Bkgnd.RightClick(" & Hwnd & "," & xs & " - xs_," & ys & " - ys_)")
  72.         Next
  73.     Case "rightd"
  74.         xy = Split(内容,"n ")
  75.         For xy(1)
  76.             Call Plugin.File.WriteLine(已转换文件,"Call Plugin.Bkgnd.RightDown(" & Hwnd & "," & xs & " - xs_," & ys & " - ys_)")
  77.         Next
  78.     Case "rightu"
  79.         xy = Split(内容,"p ")
  80.         For xy(1)
  81.             Call Plugin.File.WriteLine(已转换文件,"Call Plugin.Bkgnd.RightUp(" & Hwnd & "," & xs & " - xs_," & ys & " - ys_)")
  82.         Next
  83.     Case "middle"
  84.         xy = Split(内容,"k ")
  85.         For xy(1)
  86.             Call Plugin.File.WriteLine(已转换文件,"Call Plugin.Bkgnd.MiddleClick(" & Hwnd & "," & xs & " - xs_," & ys & " - ys_)")
  87.         Next
  88.     Case "moveto"
  89.         xy = Split(内容,"o "):xyArr = Split(xy(1),","):xs = xyArr(0):ys = xyArr(1)
  90.         Call Plugin.File.WriteLine(已转换文件,"//*******************" & 内容 & ":脚本仅记下移动坐标,但并不写出移动语句,那是无意义的")
  91.     Case "mover "
  92.         xy = Split(内容,"R "):xyArr = Split(xy(1),","):xs = xs + xyArr(0):ys = ys + xyArr(1)
  93.         Call Plugin.File.WriteLine(已转换文件,"//******************" & 内容 & ":脚本仅记下移动坐标,但并不写出移动语句,那是无意义的")
  94.     Case "mousew"
  95.         Call Plugin.File.WriteLine(已转换文件,"//" & 内容 & "系统不知道该如何处置此语句")
  96.     Case "savemo"
  97.         xss = xs:yss = ys
  98.     Case "redtor"
  99.         xs = xss:ys = yss
  100.     Case "lockmo"
  101.             Call Plugin.File.WriteLine(已转换文件,"//********************" & 内容 & "系统不知道该如何处置此语句")
  102.     Case "unlock"
  103.             Call Plugin.File.WriteLine(已转换文件,"//********************" & 内容 & "系统不知道该如何处置此语句")
  104.     Case "getcur"
  105.         If Mid(内容,10,1) = "p" Then
  106.         xy = Split(内容,"s "):xyArr = Split(xy(1),","):x = xyArr(0):y = xyArr(1)
  107.         
  108.         Call Plugin.File.WriteLine(已转换文件,xyArr(0) & " = " & xs & ":" & xyArr(1) & " = " & ys)
  109.         Else
  110.         Call Plugin.File.WriteLine(已转换文件,"//********************" & 内容 & "系统不知道该如何处置此语句")
  111.         End If
  112.     Case "ifcolo"
  113.         xy = Split(内容,"r "):xyArr = Split(xy(1),",")
  114.         Call Plugin.File.WriteLine(已转换文件,"Col_ = Plugin.BkgndColor.GetPixelColor(" & Hwnd & "," & xyArr(0) & " - xs_," & xyArr(1) & " - ys_)")
  115.         Select Case xyArr(3)
  116.         Case 0
  117.                 Call Plugin.File.WriteLine(已转换文件,"If Col_ = " & xyArr(2) & " Then")
  118.         Case 1
  119.                 Call Plugin.File.WriteLine(已转换文件,"If Col_ <> " & xyArr(2) & " Then")
  120.         Case 2
  121.                 Col_ = Replace(Col_,"_C", xyArr(2))
  122.                 Call Plugin.File.WriteLine(已转换文件,"If " & Col_ & " Then")
  123.         End Select
  124.     Case "findco"
  125.         xy = Split(内容,"r "):xyArr = Split(xy,",")
  126.         If Mid(内容,10,1) = "e" Then
  127.         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) & ")")
  128.         Call Plugin.File.WriteLine(已转换文件,"_XY = Split(_XY," & Chr(34) & "|" & Chr(34) & "):" & xyArr(7) & " = _XY(0)" & ":" & xyArr(8) & " = _XY(1)")
  129.         Else
  130.         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) & ")")
  131.         Call Plugin.File.WriteLine(已转换文件,"_XY = Split(_XY," & Chr(34) & "|" & Chr(34) & "):" & xyArr(5) & " = _XY(0)" & ":" & xyArr(6) & " = _XY(1)")
  132.         EndIf
  133.     Case "findce"
  134.         xy = Split(内容,"r "):xyArr = Split(xy,",")
  135.         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) & ")")
  136.         Call Plugin.File.WriteLine(已转换文件,"_XY = Split(_XY," & Chr(34) & "|" & Chr(34) & "):" & xyArr(5) & " = _XY(0)" & ":" & xyArr(6) & " = _XY(1)")
  137.     Case "findpi"
  138.         Call Plugin.File.WriteLine(已转换文件,"//**************************" & 内容 & "系统不知道该如何处置此语句,后台并不支持找图")
  139.     Case "[scrip"
  140.         Call Plugin.File.WriteLine(已转换文件,内容)
  141.         Select Case GetHwnd
  142.         Case 1
  143.         Call Plugin.File.WriteLine(已转换文件,Hwnd & " = " & "Plugin.Window.Find(" & Chr(34) & Clas & Chr(34) & "," & Chr(34) & Title & Chr(34) & ")")
  144.         Case 2
  145.             Call Plugin.File.WriteLine(已转换文件,Hwnd & " = " & "Plugin.Window.Foreground() ")
  146.         Case 3
  147.             Call Plugin.File.WriteLine(已转换文件,Hwnd & " = " & "Plugin.Window.MousePoint()")
  148.         End Select
  149.         Call Plugin.File.WriteLine(已转换文件,"xs_ = " & 原x & ":ys_ = " & 原y)
  150.     Case Else
  151.         If InStr(内容,"findpixecolor") Then
  152.             tem = Split(内容,"=")
  153.             xy = Split(Trim(tem(1))," ")
  154.             xyArr = Split(xy,",")
  155.             Call Plugin.File.WriteLine(已转换文件,tem & " = " & "Plugin.BkgndColor.GetPixelColor(" & Hwnd & "," & xyArr(0) & " - xs_," & xyArr(1) & " - ys_)")
  156.         Else
  157.             Call Plugin.File.WriteLine(已转换文件,内容)
  158.         End If
  159.     End Select
  160.     内容2 = Plugin.File.ReadLine(待转换文件)
  161. WEnd
  162. EndScript
  163. Sub OnScriptExit
  164.     Call Plugin.File.CloseFile(待转换文件)
  165.     Call Plugin.File.CloseFile(已转换文件)
  166.     Msgbox "转换完毕"
  167. End Sub

更新日志:

已知但尚不可改正的Bug:
当附件过大时按键精灵自动关闭的Bug

临时解决方法:将脚本源文件(*.Q文件)中的 [Attachment] 一项即其所述内容剪切出来,转换后剪切回去。