SystemUtil Object
Description
An object used to control applications and processes during a run session.
IMPORTANT
The SystemUtil object is a UFT One reserved object. Reserved objects are not learned or stored in the object repository. Reserved objects enable you to retrieve or control UFT One settings or to modify UFT One behavior during a run session. Most UFT One reserved objects are described in the Utility section of the Object Model Reference.
Operations
The sections below list the built-in methods and properties that you can use as operations for the SystemUtil object.
Methods
![]() | Prevents keyboard and mouse input events from reaching applications. |
![]() | Closes all processes opened by UFT One. |
![]() | Closes a process that is the owner of a window with the specified handle. |
![]() | Closes a process according to its Process ID (PID). |
![]() | Closes a process according to its name. |
![]() | Closes all processes that are owners of windows with the specified title. |
Prints custom log messages from a UFT One test to the Windows debug stream. | |
![]() | Runs a file or application. |
![]() | Re-enables keyboard and mouse input events after a BlockInput statement was used to block them. |
BlockInput Method
Description
Prevents keyboard and mouse input events from reaching applications.
Syntax
object.BlockInput
Return Type
None
IMPORTANT
You can use this method to prevent a run session being accidentally interrupted by someone using the keyboard or mouse on a UFT One computer.
After using this method, keyboard and mouse input is blocked until one of the following occurs:
- An UnblockInput statement is used
- A run session ends or is paused for any reason (end of test run, run error, breakpoint)
- The Ctrl+Alt+Delete key combination is pressed on the keyboard
- A critical system error occurs
Example
CloseDescendentProcesses Method
Description
Closes all processes opened by UFT One.
Syntax
object.CloseDescendentProcesses
Return Type
A long integer value.
The number of instances of the application that are closed when the statement runs.
IMPORTANT
Note: UFT One initially tries to close the process by sending a WM_CLOSE message to the process window. If the process is still open after 5 seconds, UFT One terminates the process.Example
CloseProcessByHwnd Method
Description
Closes a process that is the owner of a window with the specified handle.
Syntax
object.CloseProcessByHwnd (hWnd)
Arguments
Parameter | Description |
---|---|
hWnd |
Required. An unsigned long integer value.
The handle of the window owned by the process you want to close. Tip: You can retrieve the window handle using the hwnd property. For example: Window("MyAppName").GetROProperty("hwnd") |
Return Type
A Boolean value.
- True--The specified process was successfully closed.
- False--The specified process was not closed.
IMPORTANT
Note: UFT One initially tries to close the process by sending a WM_CLOSE message to the process window. If the process is still open after 5 seconds, UFT One terminates the process.Example
CloseProcessById Method
Description
Closes a process according to its Process ID (PID).
Syntax
object.CloseProcessById (wdProcessId)
Arguments
Parameter | Description |
---|---|
wdProcessId |
Required. An unsigned long integer value.
The Process ID (PID) of the process you want to close. Tip: You can find the PID of an application by viewing the value in the Processes tab of the Windows Task Manager, or you can retrieve the value using the process id property. For example: Window("MyAppName").GetROProperty("process id") |
Return Type
A Boolean value.
- True--The specified process was successfully closed.
- False--The specified process was not closed.
IMPORTANT
Note: UFT One initially tries to close the process by sending a WM_CLOSE message to the process window. If the process is still open after 5 seconds, UFT One terminates the process.Example
CloseProcessByName Method
Description
Closes a process according to its name.
Syntax
object.CloseProcessByName (bsProcessName)
Arguments
Parameter | Description |
---|---|
bsProcessName |
Required. A String value.
The name of the process you want to close.
|
Return Type
A long integer value.
The number of instances of the application that are closed when the statement runs.
IMPORTANT
Note: UFT One initially tries to close the process by sending a WM_CLOSE message to the process window. If the process is still open after 5 seconds, UFT One terminates the process.Example
CloseProcessByWndTitle Method
Description
Closes all processes that are owners of windows with the specified title.
Syntax
object.CloseProcessByWndTitle (bsTitle, [bRegExp])
Arguments
Parameter | Description |
---|---|
bsTitle |
Required. A String value.
The title of the window owned by the process you want to close.
|
bRegExp |
Optional. A Boolean value.
Indicates whether the bsTitle argument is treated as a regular expression.
Default value = False |
Return Type
A long integer value.
The number of instances of the application that are closed when the statement runs.
IMPORTANT
Note: UFT One initially tries to close the process by sending a WM_CLOSE message to the process window. If the process is still open after 5 seconds, UFT One terminates the process.Example
PrintToDebugStream
Description
Prints custom log messages from a UFT One test to the Windows debug stream.
Tip: A useful tool for viewing debug messages is DbgView.
For more details, see the OutputDebugString function in the Windows Dev Center.
Syntax
object.PrintToDebugStream (message)
Arguments
Parameter | Description |
---|---|
message |
Required. A String value. The message to be printed to Windows debug stream. |
Return Type
None
Example
Run Method
Description
Runs a file or application.
Syntax
object.Run file, [params], [dir], [op], [mode]
Arguments
Parameter | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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.
Default value = "" | ||||||||||||||||||||||||
dir |
Optional. A String value.
The default directory of the application or file.
Default value = "" | ||||||||||||||||||||||||
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:
Default value = "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.
Default value = 1 |
Return Type
None
IMPORTANT
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.
Tip: You can also use this method to perform operations on the specified file, similar to the usage of the Windows ShellExecute command.
Example
UnblockInput Method
Description
Re-enables keyboard and mouse input events after a BlockInput statement was used to block them.
Syntax
object.UnblockInput
Return Type
None
IMPORTANT
You can use this method to unblock keyboard and mouse input that was earlier blocked using a BlockInput statement.
Example
See also: