转载: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.

可选。一个字符串值。
如果file参数中指定的是一个可执行文件,则可以使用params参数来指定该可执行文件的运行参数。

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.
The following operations can be specified for the op argument:

可选。一个字符串值。将要被执行的动作。如果该参数值为空(“”),则默认操作为open操作。
下面是op参数中可以指定的操作:

Operation

Description

open

Opens the file specified by the FileName parameter. The file can be an executable file, a document file, or a folder. Non-executable files are open in the associated application.

打开file参数中所指定的文件。文件有可能是一个可执行文件、一个文档文件、或一个文件夹。非可执行文件会被相应的应用程序打开。

edit

Launches an editor and opens the document for editing. If the FileName argument does not specify an editable document file, the statement fails.

将文件在文件编辑器中打开以进行编辑。如果file参数中指定的文件不可编辑,则本语句失败。

explore

Explores the folder specified by the FileName argument.

打开由file参数中所指定的文件夹。

find

Initiates a search starting from the specified folder path.

file参数所指定的文件夹中进行搜索。

print

Prints the document file specified by the FileName argument. If the specified file is not a printable document file, the statement fails.

打印在file参数中所指定的文档。如果参数中所指定的文档不可打印,则语句失败。

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.
Default = 1

可选。一个Integer值。
指定应用程序打开时的显示模式。可以指定以下几种打开模式。默认模式是1

Mode

Description

0
Hides the window and activates another window.
1  
Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. Specify this flag when displaying the window for the first time.
2  
Activates the window and displays it as a minimized window.
3  
Activates the window and displays it as a maximized window.
4  
Displays the window in its most recent size and position. The active window remains active.
5  
Activates the window and displays it in its current size and position.
6  
Minimizes the specified window and activates the next top-level window in the Z order.
7  
Displays the window as a minimized window. The active window remains active.
8  
Displays the window in its current state. The active window remains active.
9  
Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. Specify this flag when restoring a minimized window.
10  
Sets the show-state based on the state of the program that started the application.

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 

posted @ 2009-11-30 14:28  小e  阅读(1535)  评论(0编辑  收藏  举报