按键精灵5级试题及答案

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

1、写一个脚本,在画图工具中画圆半径不小于100,而后在圈内画正方形四角必须与圈重合。提示:推荐使用Bkgnd命令来键鼠操作。(可选)//测试操作系统windows8.1DimHwnd,Hwnd2,Hwnd3Dimx,y,x0,y0,l,n,rDimv,i,j,kSetSimMode1CallRunApp(mspaint.exe)Delay1000//查找子窗口句柄Hwnd=Plugin.Window.Find(MSPaintApp,0)Hwnd2=Plugin.Window.FindEx(Hwnd,0,MSPaintView,0)Hwnd3=Plugin.Window.FindEx(Hwnd2,0,Afx:cf0000:8,0)TracePrintHwnd&,&Hwnd2&,&Hwnd3//-----------------------------------------画圆//设置圆心坐标x0=110:y0=110//设置点间距l=5//初始化角度n=0//设置第一圈半径r=100Whilen3.1415926*2x=x0+r*cos(n)y=y0-r*sin(n)callPlugin.Bkgnd.Moveto(Hwnd3,x,y)callPlugin.Bkgnd.LeftDown(Hwnd3,x,y)Delay5//l/r:点距除以半径,取得2点间相对圆心的角度n=n+l/rWendCallPlugin.Bkgnd.LeftUp(Hwnd3,x,y)//-----------------------------------------画正方形//根据圆心和边长,计算正方形的4个角,根号2取1.41421356l=100/1.41421356x=110-l'横左y=110-l'纵坐标上x0=110+l'横右y0=110+l'纵坐标下'横线上Fori=xtox0callPlugin.Bkgnd.Moveto(Hwnd3,i,y)callPlugin.Bkgnd.LeftDown(Hwnd3,i,y)i=i+2NextCallPlugin.Bkgnd.LeftUp(Hwnd3,i,y)callPlugin.Bkgnd.Moveto(Hwnd3,x,y)callPlugin.Bkgnd.LeftDown(Hwnd3,x,y)CallPlugin.Bkgnd.Moveto(Hwnd3,x,y0)CallPlugin.Bkgnd.Moveto(Hwnd3,x0,y0)CallPlugin.Bkgnd.Moveto(Hwnd3,x0,y)callPlugin.Bkgnd.Moveto(Hwnd3,x,y)callPlugin.Bkgnd.LeftUp(Hwnd3,x,y)EndScript2、写一个脚本,要求:启动脚本后,手动移动鼠标,然后放开操作,根据移动的最后方向继续移动鼠标,并慢慢减速,碰到边缘完全静止等待下次移动。提示:命令GetCursorPos的应用。fori=1to2step0GetCursorPosx,yTracePrintx&|&yGetCursorPosx2,y2TracePrintx2&|&y2Ifxx2oryy2ThenDoWhiletrueGetCursorPosx,yTracePrintx&|&yTracePrintx2&|&y2GetCursorPosx2,y2Ifxx2oryy2Thent1=timex1=xy1=yElset2=timeIfDateDiff(s,t1,t2)2ThenexitforEndIfEndIfloopEndIfnextdx=x2-x1dy=y2-y1ScreenW=Plugin.Sys.GetScRX()ScreenH=Plugin.Sys.GetScRY()i=0DoWhiletruex=x2+dx*iy=y2+dy*iIfx=0Theni=-x2/dxy=y2-dy*x2/dxx=0ExitdoEndIfIfx=ScreenWThenx=ScreenWi=(ScreenW-x2)/dxy=y2+dy*(ScreenW-x2)/dxExitDoEndIfIfy=0Theny=0i=-y2/dyx=x2-dx*y2/dyexitdoEndIfIfy=ScreenHTheny=ScreenHi=(ScreenH-y2)/dyx=x2+dx*(ScreenH-y2)/dyexitdoEndIfi=i+1LoopCall鼠标从当前位置先快后慢移动到目标(x,y)TracePrintx&|&ySub鼠标从当前位置先快后慢移动到目标(x2,y2)GetCursorPosx1,y1Fori=100to1step-1dx=(x2-x1)/1000000dy=(y2-y1)/1000000MoveToint(x2-i*i*i*dx),int(y2-i*i*i*dy)Delay10NextEndSub利用ShowScrTXT命令制作一个放大镜,效果类似抓抓工具的放大镜,可以放大显示鼠标指向的5*5区域的颜色.请写出代码//放大范围5*5WhileTrueCallFDJ()Delay5Wend//放大镜函数FunctionFDJ()//放大镜的起点坐标st_x=10st_y=10//获取鼠标的坐标GetCursorPosx,y//计算5*5区域范围x1=x-2x2=x+2y1=y-2y2=y+2//获取并输出5*5区域内所有颜色Fora=x1Tox2Forb=y1Toy2RtColor=Plugin.Color.GetPixelColor(a,b,1)//其中:4-x2+a=5-(x2-a+1),以下同理scr_x1=st_x+(14-x2+a)*16scr_y1=st_y+(14-y2+b)*16scr_x2=scr_x1+16scr_y2=scr_y1+16CallPlugin.Msg.ShowScrTXT(scr_x1,scr_y1,scr_x2,scr_y2,█,RtColor)NextNextEndFunction(API)利用SetWindowPos函数将窗口置前,相关说明请百度,请写出代码PrivateDeclareFunctionSetWindowPosLibuser32AliasSetWindowPos(ByValhwndAsLong,ByValhWndInsertAfterAsLong,ByValxAsLong,ByValyAsLong,ByValcxAsLong,ByValcyAsLong,ByValwFlagsAsLong)AsLongFunction窗口层次(hwnd,mode)窗口层次=SetWindowPos(hwnd,mode,0,0,0,0,3)EndFunction//---------hwnd=333123//需要控制的窗口句柄CallLib.API.窗口层次(hwnd,-1)请按以下叙述编写一个函数要求:已知一维数组a(100),a(1)=1:a(2)=2(假设下标从1开始)从数组的第三项(a(3)开始):后面的每一个元素等于前二个元素之和例如:a(3)=a(2)+a(1):a(20)=a(19)+a(18):a(100)=a(99)+a(98)现:要求编写一个具有一个参数的函数:这个参数是指定数组的下标,函数返回值是数组下标的对应值例如:我编写的函数为名f(x),那么当我带入f(50)的时候,函数的返回值应该是a(50)的值MessageBoxf(50)Functionf(x)dima(100),fa(1)=1:a(2)=2Forb=3to100a(b)=a(b-1)+a(b-2)Nextf=a(x)EndFunction

1 / 6
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功