51Testing软件测试论坛

标题: 关于MsgBox的问题 [打印本页]

作者: sumagon    时间: 2007-8-8 18:08
标题: 关于MsgBox的问题
请问下,如果我自身弹出一个提示,是否可以在脚本中将其点击掉呢?sdlkfj2
因为一旦弹出来,后面的脚本好像就暂停了。。
作者: 5am    时间: 2007-8-9 08:59
不能吧 msgbox弹出来以后robot就会暂停 你关掉msgbox以后robot应该继续吧?
作者: WUHA    时间: 2007-8-14 22:58
MsgBox 这个调试的时候可以用用,到回放 测试的时候 直接注释掉就可以了 ,
作者: sumagon    时间: 2007-8-15 08:50
标题: 回复 #3 WUHA 的帖子
因为我想在运行过程中,比如我在对比一个数据文档的时候可能会停顿一段时间在后台处理,而这一段时间会给人脚本运行中断的感觉,所以给个提示消息在这可以提示一下~
作者: 5am    时间: 2007-8-15 10:59
msgbox会让Robot暂停的 后台处理都会停掉
作者: caesarqth    时间: 2007-8-15 22:22
可以自己定义函数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

'----------------------------------------------------------------
作者: sumagon    时间: 2007-8-16 10:07
标题: 回复 #6 caesarqth 的帖子
果然是高手阿~




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