1、写一个脚本,在画图工具中画圆半径不小于100,而后在圈内画正方形四角必须与圈重合。
提示:推荐使用Bkgnd命令来键鼠操作。(可选)
//测试操作系统windows 8.1
Dim Hwnd, Hwnd2, Hwnd3
Dim x, y, x0, y0, l, n, r
Dim v, i, j, k
SetSimMode 1
Call RunApp("")
Delay 1000
//查子窗口句柄
Hwnd = Plugin.Window.Find("MSPaintApp", 0)
Hwnd2 = Plugin.Window.FindEx(Hwnd,0,"MSPaintView", 0)
Hwnd3 = Plugin.Window.FindEx(Hwnd2, 0, "Afx:cf0000:8", 0)
TracePrint Hwnd&","&Hwnd2&","&Hwnd3
//-----------------------------------------画圆
//设置圆心坐标
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)
call Plugin.Bkgnd.Moveto (Hwnd3, x, y)
call 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
call Plugin.Bkgnd.Moveto (Hwnd3, i, y)
call Plugin.Bkgnd.LeftDown (Hwnd3, i, y)
i = i + 2
Next
Call Plugin.Bkgnd.LeftUp(Hwnd3, i, y)
call Plugin.Bkgnd.Moveto (Hwnd3, x, y)
call Plugin.Bkgnd.LeftDown (Hwnd3, x, y)
Call Plugin.Bkgnd.Moveto(Hwnd3, x, y0)
Call Plugin.Bkgnd.Moveto(Hwnd3, x0, y0)
Call Plugin.Bkgnd.Moveto(Hwnd3, x0, y)
call Plugin.Bkgnd.Moveto (Hwnd3, x, y)
call Plugin.Bkgnd.LeftUp (Hwnd3,x , y)
EndScript
2、写一个脚本,要求:启动脚本后,手动移动鼠标,然后放开操作,根据移动的最后方向继续移动鼠标,并慢慢减速,碰到边缘完全静止等待下次移动。
提示:命令GetCursorPos的应用。
for i=1 to 2 step 0
GetCursorPos x, y
TracePrint x&"|"&y
GetCursorPos x2, y2
TracePrint x2&"|"&y2
If x <> x2 or y <> y2 Then
Do While true
GetCursorPos x, y
TracePrint x & "|" & y
TracePrint x2&"|"&y2
GetCursorPos x2, y2
If x <> x2 or y <> y2 Then
t1=time
x1 = x
y1 = y
Else
t2 = time
If DateDiff("s", t1, t2) > 2 Then
exit for
End If
End If
loop
End If
next
dx =x2-x1
dy = y2 - y1
ScreenW = Plugin.Sys.GetScRX()
ScreenH = Plugin.Sys.GetScRY()
i=0
Do While true
x=x2 + dx*i
y = y2 + dy * i
If x <= 0 Then
i = - x2 / dx
y = y2 - dy * x2 / dx
x = 0
Exit do
End If
If x >= ScreenW Then
x = ScreenW
i = (ScreenW - x2) / dx
y = y2 + dy * (ScreenW - x2) / dx
Exit Do
End If
If
y <= 0 Then
y = 0
i = - y2 / dy
x = x2 - dx * y2 / dy
exit do
End If
If y >= ScreenH Then
y = ScreenH
i = (ScreenH - y2) / dy
x = x2 + dx * (ScreenH - y2) / dy
exit do
End If
i=i+1
Loop
Call 鼠标从当前位置先快后慢移动到目标(x, y)
TracePrint x&"|"&y
Sub 鼠标从当前位置先快后慢移动到目标(x2,y2)
GetCursorPos x1, y1
For i= 100 to 1 step -1
dx = (x2 - x1) / 1000000
dy = (y2 - y1) /1000000
MoveTo int(x2 - i * i * i * dx), int(y2 - i * i * i * dy)
Delay 10
Next
End Sub
利用 ShowScrTXT 命令制作一个放大镜,效果类似抓抓工具的放大镜,可以放大显示鼠标指向的5*5区域的颜.请写出代码
//放大范围5*5
While True
Call FDJ()
Delay 5
Wend
//放大镜函数
Function FDJ()
//放大镜的起点坐标
st_x = 10
st_y = 10
//获取鼠标的坐标
GetCursorPos x, y
//计算5*5区域范围
x1 = x - 2
x2 = x + 2
y1 = y - 2
请输入长度介于05之间的字符串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 + (14 - x2 + a) * 16
scr_y1 = st_y + (14 - y2 + b) * 16
scr_x2 = scr_x1 + 16
scr_y2 = scr_y1 + 16
Call Plugin.Msg.ShowScrTXT(scr_x1, scr_y1, scr_x2, scr_y2, "█", RtColor)
Next
Next
End Function
(API)利用 SetWindowPos 函数将窗口置前,相关说明请百度,请写出代码
Private Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Function 窗口层次(hwnd, mode)
窗口层次 = SetWindowPos(hwnd, mode, 0, 0, 0, 0, 3)
End Function
//---------
hwnd = 333123//需要控制的窗口句柄
Call Lib.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)的值
MessageBox f(50)
Function f(x)
dim a(100),f
a(1)=1:a(2)=2
For b=3 to 100
a(b)=a(b-1)+a(b-2)
Next
f=a(x)
End Function
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论