51Testing软件测试论坛

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

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 2542|回复: 10
打印 上一主题 下一主题

[求助] 这段QTP帮助中的代码没看明白,望指教

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2007-11-30 18:37:42 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
示例
以下示例在整个屏幕中搜索单词 Mercury,并在找到该单词时单击它。

l = -1

t = -1

r = -1

b = -1

Succeeded = TextUtil.GetTextLocation("16",0,l,t,r,b)

If Not Succeeded Then

MsgBox "找不到文本"

else

x = (l+r) / 2

y = (t+b) / 2

Set dr = CreateObject("Mercury.DeviceReplay")

dr.MouseClick x, y, 0

End If

其中的“16”是什么意思,怎么看都不懂,望大家指点
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

该用户从未签到

2#
发表于 2007-11-30 19:00:07 | 只看该作者
按照你的题意我觉得16应该换成"Mercury",不知道我说的对不对
回复 支持 反对

使用道具 举报

该用户从未签到

3#
 楼主| 发表于 2007-12-3 10:13:05 | 只看该作者
更让我不解的是其中的Mercury对象,是什么意思,哪里能找到相关的帮助,希望高人能指教一下
回复 支持 反对

使用道具 举报

该用户从未签到

4#
发表于 2007-12-3 10:57:40 | 只看该作者
Set dr = CreateObject("Mercury.DeviceReplay")
我理解这个是设一个可以做回放操作的对象。
回复 支持 反对

使用道具 举报

该用户从未签到

5#
发表于 2007-12-3 11:12:34 | 只看该作者
哪来的这段文字阿?
我记得帮助里关于GetTextLocation不是这样描述的阿
回复 支持 反对

使用道具 举报

该用户从未签到

6#
发表于 2007-12-3 12:08:06 | 只看该作者
不懂.
回复 支持 反对

使用道具 举报

该用户从未签到

7#
发表于 2007-12-3 16:51:03 | 只看该作者
"Device Replay"是在提供坐标位置以后可以实现的鼠标和键盘操作。这个函数不能自动录制,需要在expert view中编程。
它有以下这些函数:
MouseMove x, y: Move the mouse to the screen coordinate (x,y).
MouseClick x, y, button: Move the mouse to the screen coordinate (x,y) and click the button(0=left; 1=middle; 2=right).
MouseDblClick x, y, button: Move the mouse to the screen coordinate (x,y) and double-click the button(0=left; 1=middle; 2=right).
DragAndDrop x, y, dropx, dropy, button: Drag the mouse from screen coordinate (x,y) to (dropx,dropy) with the button(0=left; 1=middle; 2=right) pressed.
PressKey key: Press a key using the ASCII code of the key.For example, Chr(13), vbCR and vbTab.
MouseDown x, y, button: Press the mouse button on screen coordinate (x,y).
MouseUp x, y, button: Release the mouse button on screen coordinate (x,y).
KeyDown key: Press a key using the ASCII code of the key.For example, Chr(13), vbCR and vbTab.
KeyUp key: Release a key using the ASCII code of the key.For example, Chr(13), vbCR and vbTab.
SendString string: Type a string.
回复 支持 反对

使用道具 举报

该用户从未签到

8#
 楼主| 发表于 2007-12-3 18:01:43 | 只看该作者
关于我3楼的提问还是没懂
回复 支持 反对

使用道具 举报

  • TA的每日心情
    开心
    2016-2-27 08:48
  • 签到天数: 2 天

    连续签到: 1 天

    [LV.1]测试小兵

    9#
    发表于 2007-12-3 21:35:31 | 只看该作者
    查看一下帮助里面对 GetTextLocation的说明,不就明白了吗? 另外,楼主的代码是从哪里找到的?
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    10#
    发表于 2007-12-3 22:30:10 | 只看该作者
    这段说明说的很详细了啊!
    description:
    Checks whether a specified text string is contained in a specified window area. If the

    text string is located, the location coordinates are also returned.

    描述:
    检查特定的字符串是否存在指定的windows区域。如果这段字符串存在,就返回这个位置的坐标。


    用法:
    TextUtil.GetTextLocation(TextToFind, hWnd, Left, Top, Right, Bottom

    [,MatchWholeWordOnly])

    domo中的“16” 就是第一个参数 TextToFind

    Argument :TextToFind
    Type :    String  
    Description :The text string you want to locate.  

    参数:TextToFind
    类型: 字符串
    描述:你想定位的字符串。


    这些帮助文档都有的哦,多查查再问比较好!加油!
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    11#
     楼主| 发表于 2007-12-4 18:20:14 | 只看该作者
    看意思感觉是很好理解,但操作时发现不是那么回事啊,16我怀疑是帮助里面打错了吧,至于后面的Mercury对象应该是另一回事,谁能提供一个好的例子让我来实验一下,这个例子应该不是贴上就能运行的吧,反正我每次执行都只会显示找不到文本,不知道怎样才能找到
    回复 支持 反对

    使用道具 举报

    本版积分规则

    关闭

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

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

    GMT+8, 2024-9-25 17:22 , Processed in 0.076486 second(s), 27 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

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