转载:systemutil.run
Run Method
Description
Runs a file or application.
运行一个文件或应用程序。
Syntax
object.Run file, [params], [dir], [op], [mode]
Argument |
Description |
object |
A test object of type SystemUtil. SystemUtil类型的测试对象。 |
file |
Required. A String value. The name of the file you want to run. 必须。一个字符串值。 |
params |
Optional. A String value. If the specified file argument is an executable file, use the params argument to specify any parameters to be passed to the application. 可选。一个字符串值。 |
dir |
Optional. A String value. The default directory of the application or file. 可选。一个字符串值。 |
op |
Optional. A String value. The action to be performed. If this argument is blank ( ""), the open operation is performed. 可选。一个字符串值。将要被执行的动作。如果该参数值为空(“”),则默认操作为open操作。 |
mode |
Optional. An Integer value. Specifies how the application is displayed when it opens. You can specify one of the modes in the table below. 可选。一个Integer值。
|
Return Value
None
Remarks
When specifying a non-executable file, the file opens in the associated application.
当指定的是一个非可执行文件时,文件被相应的应用程序打开。
Note: A SystemUtil.Run statement is automatically added to your test when you run an application from the Start menu or the Run dialog box while recording a test.
注意:在录制脚本的过程中,如果你从系统的“开始”菜单或“运行”对话框中运行应用程序时,SystemUtil.Run语句会自动添加到脚本中。
Tip: You can also use this method to perform operations on the specified file, similar to the usage of the Windows ShellExecute command.
Tip:你也可以使用本方法对指定的文件进行操作,该功能类似于使用Windows ShellExecute命令。
Example
Open a Text File in the Default Text Application (Notepad)
本例使用Run方法打开了一个名为type.txt的文件(txt类型文件的默认打开程序是Notpad),然后向文件中输入“happy days”文字,然后使用快捷键保存该文件,然后关闭NotePad应用程序。
Sub CloseDescendentProcesses_Example()
SystemUtil.Run "C:\type.txt", "", "", ""
Window("Text:=type.txt - Notepad").Type "happy days"
Window("Text:=type.txt - Notepad").Type micAltDwn & "F" & micAltUp
Window("Text:=type.txt - Notepad").Type micLShiftDwn & "S" & micLShiftUp
Window("Text:=type.txt - Notepad").Close
End Sub