51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 3531|回复: 2
打印 上一主题 下一主题

[Robot] robot使用的例子

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2007-9-25 14:38:39 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
'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
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

该用户从未签到

2#
发表于 2007-9-30 17:52:53 | 只看该作者
看不明白,才刚开始学习
回复 支持 反对

使用道具 举报

该用户从未签到

3#
发表于 2007-10-11 11:09:45 | 只看该作者
好好學習,天天向上!
回复 支持 反对

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-11-24 13:37 , Processed in 0.096854 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表