51Testing软件测试论坛

标题: robot使用的例子 [打印本页]

作者: jiangyuetian    时间: 2007-9-25 14:38
标题: robot使用的例子
'Initially Recorded: 2003-8-13  14:56:41
'Script Name: test
'Author : tester3911

Type Rect
    l as integer
    r as integer
    t as integer
    b as integer
End Type

declare sub begins
declare sub clear
declare sub seltool(k) ' 1 - point 2 - line 3 - rectangle 4 - ellipse
declare sub drawsin
declare sub drawhelix
declare sub drawtp 'draw two point types
declare sub drawrand(count) 'draw two point types randomize
declare sub exits
declare function rand(lower as integer,upper as integer) as integer 'rand function
Sub Main
    Dim Result As Integer

    begins
    seltool(1)
    drawsin
    clear
    seltool(1)
    drawhelix
    clear
    seltool(3)
    drawtp
    clear
    seltool(4)
    drawrand(20)
    clear
    exits
End Sub

sub begins
    StartApplication "mspaint.exe"
   
    Window SetContext, "Caption=未命名 - 画图", ""
    Window WMaximize, "", ""
    MenuSelect "图像(I)->属性(A)..."
   
    Window SetContext, "Caption=属性", ""
    InputKeys "500{TAB}500{ENTER}"

end sub
sub clear
    Window SetContext, "Caption=未命名 - 画图", ""
    InputKeys "^a{DELETE}"
end sub

sub seltool(k)
    select case k
    case 1
        Window SetContext, "Caption=未命名 - 画图", ""
        GenericObject Click, "Class=AfxWnd;ClassIndex=2;VisualText=工具", "Coords=40,91"
        GenericObject Click, "Class=AfxWnd;ClassIndex=2;VisualText=工具", "Coords=29,219"   
    case 2
        Window SetContext, "Caption=未命名 - 画图", ""
        GenericObject Click, "Class=AfxWnd;ClassIndex=2;VisualText=工具", "Coords=11,144"
        GenericObject Click, "Class=AfxWnd;ClassIndex=2;VisualText=工具", "Coords=34,218"
    case 3
        Window SetContext, "Caption=未命名 - 画图", ""
        GenericObject Click, "Class=AfxWnd;ClassIndex=2;VisualText=工具", "Coords=10,171"
        GenericObject Click, "Class=AfxWnd;ClassIndex=2;VisualText=工具", "Coords=33,224"
    case 4
        Window SetContext, "Caption=未命名 - 画图", ""
        GenericObject Click, "Class=AfxWnd;ClassIndex=2;VisualText=工具", "Coords=15,195"
        GenericObject Click, "Class=AfxWnd;ClassIndex=2;VisualText=工具", "Coords=28,223"
    end select   

end sub

sub drawsin
    Msgbox "画一个正弦函数"
    const pi = 3.1415926
    const w = 400
    const h = 300
    const wo = 2 * pi
    const ho = 2
    const offsetx = 10
    const offsety = 30
    dim  x as single,y as single
    dim i as integer,j as integer
    dim strCoords as string
    for x = -pi to pi step .1
        y = sin(x)
        i = Int(w * (x / wo + 1 /ho)) + offsetx
        j = Int(h * (- y + 1 ) / ho) + offsety
        strCoords = Format(i) + "," + Format(j)
        GenericObject Click, "Class=Afx:;ClassIndex=1", "Coords=" + strCoords
    next x
    msgbox "绘制完成"
end sub

sub drawhelix
    Msgbox "画一个螺旋函数"
    const pi = 3.1415926
    const w = 400
    const h = 400
    const wo = 10
    const ho = 10
    const offsetx = 150
    const offsety = 200
    dim rou as single,theta as single
    dim  x as single,y as single
    dim i as integer,j as integer
    dim strCoords as string
    for theta = 0 to 2 * pi step .1
        rou = theta
        x = rou * cos(theta)
        y = rou * sin(theta)
        i = Int(w * (x / wo + 1 /ho)) + offsetx
        j = Int(h * (- y + 1 ) / ho) + offsety
        strCoords = Format(i) + "," + Format(j)
        GenericObject Click, "Class=Afx:;ClassIndex=1", "Coords=" + strCoords
    next theta
    msgbox "绘制完成"

end sub
sub exits
    Window SetContext, "Caption=未命名 - 画图", ""
    Window CloseWin, "", ""
    Window SetContext, "Caption=画图", ""
    PushButton Click, "Text=否(N)"

end sub

sub drawtp
    Msgbox "平铺矩形"
    const w = 420
    const h = 420
    const offsetx = 10
    const offsety = 10
    const brickx = 50
    const bricky = 50
    dim i,j,s$
    dim r as Rect
    for i = 1 to h / bricky
        r.t = i * bricky + offsety
        r.b = r.t + bric
作者: rjcs05121    时间: 2007-9-30 17:52
看不明白,才刚开始学习
作者: fsxfbeyond    时间: 2007-10-11 11:09
好好學習,天天向上!




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2