自己改的一个简单的脚本,请高手帮忙看看为什么行不通
Sub MainDim Result As Integer
'Initially Recorded: 2006-10-2716:49:13
'Script Name: 画图
StartApplication "C:\WINDOWS\system32\mspaint.exe"
Window SetContext, "Caption=未命名 - 画图", ""
Window WMaximize, "", ""
Window SetContext, "Caption=未命名 - 画图", ""
Msgbox "画一个图形","0","判断"
Window SetContext, "Caption=判断", ""
PushButton Click, "Text=OK"
End Sub
我是个刚接触测试的新人,上面是我学习ROBOT中的自己改的一个简单的脚本,可是提示说 Window SetContext, "Caption=判断", ""有错误,请高手指教sdlkfj2先谢谢了啊 当你执行到这个语句的时候:Msgbox "画一个图形","0","判断",程序便挂起了,等待着与你的交互,所以低下的 Window SetContext, "Caption=判断", "" PushButton Click, "Text=OK" 并不能被执行。这样不知道适不适合你的要求:
--
Global iTime as Integer
Declare Function TimedDlgFunc(id As String, Action As Integer, Suppvalue As Long) As Integer
Declare Function SQAMsgBox(sMsgText as String, Optional vMsgCaption as Variant, Optional vTimeOut as Variant) as Integer
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 'Dialog box Initialization
StartTime = Timer
If StartTime + iTime >= 86400 Then
StartTime = 86400 - StartTime - iTime
End If
TimedDlgFunc = 1
Case 2 'Button pushed or any control changed (except typing in text or combo box)
Select Case Suppvalue
Case 1
DlgEnd -1
Case 2
DlgEnd 0
Case Else
TimedDlgFunc = 0
End Select
Case 3 'Change in text or combo box contents
TimedDlgFunc = 1
Case 4 'Change of control focus
TimedDlgFunc = 1
Case 5 'Idle state (return 0 to prevent this being continually called)
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
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
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 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
Sub Main
Dim Result As Integer
'Initially Recorded: 2006-10-2716:49:13
'Script Name: »­Í¼
StartApplication "C:\WINDOWS\system32\mspaint.exe"
Window SetContext, "Caption=untitled - Paint", ""
Window WMaximize, "", ""
Msgbox "画一个图形","0","判断"
Window SetContext, "Caption=untitled - Paint", ""
SQAMsgBox 画一个图形","判断",10
End Sub
--- 谢谢啊 代码我研究了,很受益。
可是我的本意 是想让它实现鼠标自动点击弹出的msgbox的“确定”按钮,从而进行下面的画图操作,不知道能不能实现呢?就象我录制脚本的时候 关闭某个文件时候会弹出 “是否关闭”按钮,然后在回放过程中这个点击按钮的动作也是自动的,是能真正看到鼠标的动作的一个操作。 我是个新人 希望大家多多帮助呀 原帖由 hepingisme 于 2006-10-29 10:44 发表
谢谢啊 代码我研究了,很受益。
可是我的本意 是想让它实现鼠标自动点击弹出的msgbox的“确定”按钮,从而进行下面的画图操作,不知道能不能实现呢?就象我录制脚本的时候 关闭某个文件时候会弹出 “是否关闭 ...
我也是新人,我估计:一旦调用msgbox这个函数,msgbox会产生一个模态对话框,程序挂起,等待用户交互(非模态对话框就象Notepad里面的 查找替换dialog,它弹出后,你仍然可以选中后面Notepad里的字段),如此说来Robot就挂起了,等待着你的输入或者点击,也就是说,Robot不会去执行下面的 Window SetContext, "Caption=判断", ""PushButton Click, "Text=OK" 这两段代码。除非你手动去点击这个对话框,或者用其他方法代替,例如别人提供的倒计时对话框。 谢谢啊 能不能留个QQ或者MSN号 给我, 希望以后能经常向您 请教.sdlkfj2
我的QQ172017409
MSN:hepingisme◎163.com
[ 本帖最后由 hepingisme 于 2006-11-4 15:40 编辑 ]
页:
[1]