51Testing软件测试论坛

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

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 3007|回复: 6
打印 上一主题 下一主题

[Robot] 关于MsgBox的问题

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2007-8-8 18:08:53 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
请问下,如果我自身弹出一个提示,是否可以在脚本中将其点击掉呢?sdlkfj2
因为一旦弹出来,后面的脚本好像就暂停了。。
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

该用户从未签到

2#
发表于 2007-8-9 08:59:41 | 只看该作者
不能吧 msgbox弹出来以后robot就会暂停 你关掉msgbox以后robot应该继续吧?
回复 支持 反对

使用道具 举报

该用户从未签到

3#
发表于 2007-8-14 22:58:29 | 只看该作者
MsgBox 这个调试的时候可以用用,到回放 测试的时候 直接注释掉就可以了 ,
回复 支持 反对

使用道具 举报

该用户从未签到

4#
 楼主| 发表于 2007-8-15 08:50:58 | 只看该作者

回复 #3 WUHA 的帖子

因为我想在运行过程中,比如我在对比一个数据文档的时候可能会停顿一段时间在后台处理,而这一段时间会给人脚本运行中断的感觉,所以给个提示消息在这可以提示一下~
回复 支持 反对

使用道具 举报

该用户从未签到

5#
发表于 2007-8-15 10:59:06 | 只看该作者
msgbox会让Robot暂停的 后台处理都会停掉
回复 支持 反对

使用道具 举报

该用户从未签到

6#
发表于 2007-8-15 22:22:07 | 只看该作者
可以自己定义函数SQAMsgbox,指定时间后对话框自动消失
在论坛里有人发的贴,你可以搜一下函数名
SQAMsgbox “指定时间消失”,“标题”,120,120秒后对话框自动消失

Global iTime as Integer     'used by SQAMsgBox function
'Dim TotalTime As Integer   'used by TimedMsgBox sub

Declare Function TimedDlgFunc(id As String, Action As Integer, SuppValue As Long) As Integer

'----------------------------------------------------------------
'TimedDlgFunc
'============
'function to process user actions in the SQAMsgBox dialog box
'(original function by Andy Tinkham, modified by Paul Downes)
'input   : id        = identifies the dialog control that triggered the call
'                      to the dialog function
'        : Action    = integer from 1 to 5 identifying the reason why the
'                      dialog function was called
'        : SuppValue = specific info about why the dialog function was called
'returns :

Function TimedDlgFunc(id As String, Action As Integer, SuppValue As Long) As Integer
    Static StartTime
    Dim EndTime
    Dim vTimeoutValue as Variant

    Select Case Action
        Case 1
                StartTime = Timer
    'Check to see if StartTime + TotalTime is greater than 86400
    '(the total number of seconds in a day). If it is, change the
    'value so that it is negative so that when the Timer function
    'wraps back to 0 at midnight, the dialog still goes away at the
    'appropriate time.
                If StartTime + iTime >= 86400 Then
                        StartTime = 86400 - StartTime - iTime
                End If
                TimedDlgFunc = 1
        Case 2
            Select Case SuppValue
                Case 1
                    DlgEnd -1
                Case 2
                    DlgEnd 0
                Case Else
                    TimedDlgFunc = 0
            End Select

        Case 3
                TimedDlgFunc = 1
        Case 4
                TimedDlgFunc = 1
        Case 5
                EndTime = Timer
                If (EndTime - StartTime) >= iTime Then
                        DlgEnd -1
                End If
                vTimeoutValue = Format(iTime - (EndTime - StartTime), "#.#")
                DlgText DlgControlID("txtTimeValue"), CStr(vTimeoutValue)
                TimedDlgFunc = 1
    End Select

End Function

'----------------------------------------------------------------
'SQAMsgBox
'=========
'timed message box; displays timeout countdown; if user selects "OK" or on timeout,
'returns sqaPass; if user selects "Cancel", returns sqaFail
'input   : sMsgText    = message to display
'        : vMsgCaption = (optional) dialog box caption
'        : vTimeOut    = (optional) timeout period in seconds (default = 20)
'returns : sqaPass on timeout or when OK button selected; sqaFail if Cancel selected

Function SQAMsgBox(sMsgText as String, Optional vMsgCaption as Variant, Optional vTimeOut as Variant) as Integer
    Dim Result as Integer
    Dim TotalTime As Integer
    Dim sCmdText as String   
    Dim sTimeoutText as String
    Dim vValue as Variant

'command message displayed
    sCmdText = "Press OK to continue execution, Cancel to stop script."
   
'set defaults for optional parameters, if missing   
    If IsMissing(vMsgCaption) Then
        vMsgCaption = "SQAMsgBox"
    End If
    If IsMissing(vTimeOut) Then
        vTimeOut = 20       'seconds
    End If

    sTimeoutText = "Timeout: "
   
'-----
    Begin Dialog dlgMsgBox 200, 80, vMsgCaption, .TimedDlgFunc
        GroupBox 5, 2, 190, 40, "", .grpMsgTxt
        Text 15, 11, 175, 25, sMsgText, .txtMsgText
        Text 15, 47, 180, 20, sCmdText, .txtCmdText
'--------------
'        Button 40, 60, 40, 14, "&OK", .btnOK
'        Button 120, 60, 40, 14, "&Cancel", .btnCancel
'--------------
'        Button 100, 60, 40, 14, "&OK", .btnOK
'        Button 150, 60, 40, 14, "&Cancel", .btnCancel
'        Text 15, 63, 30, 10, sTimeoutText, .txtTimeText
'        Text 50, 63, 20, 10, vTimeout, .txtTimeValue
'--------------
        Button 20, 60, 40, 14, "&OK", .btnOK
        Button 140, 60, 40, 14, "&Cancel", .btnCancel
        Text 78, 63, 30, 10, sTimeoutText, .txtTimeText
        Text 108, 63, 20, 10, vTimeout, .txtTimeValue
    End Dialog
'-----

    Dim TimedDlg As dlgMsgBox
    iTime = CInt(vTimeOut)
    Result = Dialog(TimedDlg)
   
    If Result = 2 Then
        SQAMsgBox = sqaFail
    Else
        SQAMsgBox = sqaPass
    End If   
   
End Function

'----------------------------------------------------------------
' Original function, by Andy Tinkham

'* Syntax:
'*
'*      Call TimedMsgBox ("message", "caption", 20)
'*

'Sub TimedMsgBox (MsgText As String, MsgCaption As String, TimeToShow As Integer)

'    Begin Dialog dlgMsgBox 200, 100, MsgCaption, .TimedDlgFunc
'        Text 15, 12, 170, 80, MsgText, .txtMsgText
'        Button 80, 80, 40, 14, "OK", .btnOK
'    End Dialog

'    Dim TimedDlg As dlgMsgBox

'    TotalTime = TimeToShow

'    Dialog TimedDlg

'End Sub

'----------------------------------------------------------------
回复 支持 反对

使用道具 举报

该用户从未签到

7#
 楼主| 发表于 2007-8-16 10:07:15 | 只看该作者

回复 #6 caesarqth 的帖子

果然是高手阿~
回复 支持 反对

使用道具 举报

本版积分规则

关闭

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

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

GMT+8, 2024-9-23 22:25 , Processed in 0.071450 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

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