GetMainWindowHandle

The GetMainWindowHandle component retrieves the window handle of the main window of the corresponding process. It accepts the Process Id as input and returns the IntPtr value of the specified process.

Screenshot

Ports

The GetMainWindowHandle component exposes the Control In, Control Out, Data In, and Data Out ports by default.

Port Description
Control In Must be connected to the Control Out port of one or more components.
Control Out Can be connected to the Control In port of another component or the default end component.
Data In Specified the process ID of the process (string).
Data Out Returns the value of the specified process (intptr).

Properties

To edit the properties of the GetMainWindowHandle component, in the Properties window, change the required property. You can edit the following properties.

Property Description
Search Search for the respective property.
Delay After Execution Specifies the wait time (in seconds) after the action is performed.
Delay Before Execution Specifies the wait time (in seconds) before the action is performed.

Example

Let us consider an example.

Screenshot

To retrieve the window handle of the main window:

  1. In the Toolbox, expand Utilities and then expand System Process.

  2. To specify the process ID of the process:

    • In the Toolbox, expand General.
    • Drag the Variable component and drop it on the Design surface.
    • Double-click the edit text box and enter the required process ID.

    Note

    To learn more about the Variable component, refer the Variable section.

  3. Drag the GetMainWindowHandle component and drop it on the Design surface.

  4. To override the existing data source, right-click the processId box.
  5. Click Override and change the data source.

    Note

    To learn more about overriding the data source of the data port, refer the Override section.

  6. Connect the control ports and data ports in the activity.

  7. In the toolbar, click Run.
    The component returns the window handle of the main window of the specified process.