4题是抄的,只是为了过级。最后得93分,可能代码还是不够最优,有看出的大大希望能不吝指点。
1、写一个脚本,要求启动时,记录(录制)当前鼠标的移动轨迹,记录结束时,执行反相操作,注意操作速度不可偏差过大。
//就是循环记录鼠标位置再移动的过程,代码略
//1 颜色判断,目标程序中经常变动的2个点颜色,如果在一定的时间内没有变化,说明程序卡死 /*---------------------------------------------------------------------------------------*/ MessageBox "以下是第一种判断方式,颜色判断" & vbcrlf & vbcrlf _ & "为了正常结束脚本,请不要在运行期间手动操作" & vbcrlf & vbcrlf _ & "点击确定继续。" /*---------------------------------------------------------------------------------------*/ Dim err err = true counts=0 '回到桌面 KeyDown "Win", 1 KeyPress "D", 1 KeyUp "Win", 1 While err IfColor 450,200,"ffffff",1 Then counts = counts + 1 End If IfColor 250,260,"ffffff",1 Then counts = counts + 1 End If '多次验证防止误判 If counts > 5 Then err = False MessageBox Hwnd & " 检测到已经卡死,点击确定继续。" End If Delay 500 Wend /*------------------------------------------------------------------------------------------------------*/ MessageBox "以下是第二种判断方式,API检测目标程序是否挂起" & vbcrlf & "点击确定继续。" /*------------------------------------------------------------------------------------------------------*/ //2 API看目标程序是否挂起 Private Declare Function IsHungAppWindow Lib "user32.dll" (ByVal hwnd As Long) As Long Dim Hwnd Hwnd = Plugin.Window.MousePoint() If IsHungAppWindow(Hwnd) = 0 Then '0正常;1无响应 MessageBox Hwnd & " 正常,点击确定退出脚本。" Else MessageBox Hwnd & " 卡死(无响应),点击确定退出脚本。" '相关处理代码 End If EndScript
//写一个脚本,在画图工具中画圆半径不小于100,而后在圈内画正方形四角必须与圈重合。 //提示:推荐使用Bkgnd命令来键鼠操作。(可选) Dim Hwnd, Hwnd2, Hwnd3 Dim x, y, x0, y0, l, n, r Dim v, i, j, k SetSimMode 1 Call RunApp("mspaint.exe") Delay 1000 //查找子窗口句柄 Hwnd = Plugin.Window.Find("MSPaintApp", 0) Hwnd2 = Plugin.Window.FindEx(Hwnd,0,"AfxFrameOrView42u", 0) Hwnd3 = Plugin.Window.FindEx(Hwnd2,0,"Afx:1000000:8", 0) //-----------------------------------------画圆 //设置圆心坐标 x0=110:y0=110 //设置点间距 l=5 //初始化角度 n=0 //设置第一圈半径 r=100 While n < 3.1415926 * 2 x=x0+r*cos(n) y = y0 - r * sin(n) Plugin.Bkgnd.Moveto Hwnd3, x, y Plugin.Bkgnd.LeftDown Hwnd3, x, y Delay 5 // l/r:点距除以半径,取得2点间相对圆心的角度 n = n + l / r Wend Call Plugin.Bkgnd.LeftUp(Hwnd3, x, y) //-----------------------------------------画正方形 //根据圆心和边长,计算正方形的4个角,根号2取1.41421356 l = 100 / 1.41421356 x = 110 - l '横左 y = 110 - l '纵坐标上 x0 = 110 + l '横右 y0 = 110 + l '纵坐标下 '横线上 For i = x to x0 Plugin.Bkgnd.Moveto Hwnd3, i, y Plugin.Bkgnd.LeftDown Hwnd3, i, y i = i + 2 Next Call Plugin.Bkgnd.LeftUp(Hwnd3, i, y) //2013-8-16补充,因为是直线,直接给出开始坐标和结束坐标就好,不需要循环... ... 如下: Plugin.Bkgnd.Moveto Hwnd3, x, y Plugin.Bkgnd.LeftDown Hwnd3, x, y Plugin.Bkgnd.Moveto Hwnd3, x, y0 Plugin.Bkgnd.LeftUp(Hwnd3,x , y0) //省略部分,同上 EndScript
Dim x, y, x1, x2, y1, y2, st_x, st_y Dim scr_x1, scr_y1, scr_x2, scr_y2 MessageBox "【确定】后开始运行放大镜,【F12】键退出。" While True Call FDJ() Delay 10 Wend //放大镜函数 Function FDJ() //放大镜的起点坐标 st_x = 0 st_y = 0 //获取鼠标的坐标 GetCursorPos x, y //计算5*5区域范围 x1 = x - 2 x2 = x + 2 y1 = y - 2 y2 = y + 2 //获取并输出5*5区域内所有颜色 For a = x1 To x2 For b = y1 To y2 RtColor = Plugin.Color.GetPixelColor(a, b, 1) //其中:4 - x2 + a = 5 - (x2 - a + 1),以下同理 scr_x1 = st_x + (4 - x2 + a) * 6 scr_y1 = st_y + (4 - y2 + b) * 6 scr_x2 = scr_x1 + 6 scr_y2 = scr_y1 + 6 Call Plugin.Msg.ShowScrTXT(scr_x1, scr_y1, scr_x2, scr_y2, "█", RtColor) Next Next End Function
5、筛选出100以内所有个位数加十位数等于10的数,例如82,8+2=10满足条件,请写出代码
//代码略