activities
latest
false
UiPath logo, featuring letters U and I in white
UI Automation Activities
Last updated Nov 25, 2024

Create and Override Files

The example below explains how to create a new notepad file, edit it, and save it. It presents activities such as Send Hotkey, Click, Type Into, or Element Exists. You can find these activities in the UiPath.UIAutomation.Activities package.

This is how the automation process can be built:

  1. Open Studio and create a new Process.
  2. Drag a Sequence container in the Workflow Designer.

    • Create the following variable:

      Variable Name

      Variable Type

      Default Value

      FileAlreadyExists

      Boolean

       
  3. Drag a Send Hotkey activity inside the Sequence container.

    • Select the check box for the Win option and add the value r in the Key field. This specifies the command that needs to be executed by the automation process.
    • Inside the activity, click the Indicate on screen option. Now you can select the desired application. The GIF below shows all the steps you need to follow:



  4. Place a Type Into activity below the Send Hotkey activity.

    • Inside the activity, click the Indicate on screen option and select the desired area. The GIF below shows all the steps you need to follow:


    • Add the expression "notepad.exe" in the Text field. This indicates what text should be written in the selected field.
    • Select the check box for the SimulateClick option. This option simulates the click using the technology of the target application and it works in the background.
  5. Drag a Click activity below the Type Into activity.

    • Inside the activity, click the Indicate on screen option and select the Ok button. The GIF below shows all the steps you need to follow:


    • In the Properties panel, select the check box for the SimulateClick option. This option simulates the click using the technology of the target application, and it works in the background.
  6. Place a Type Into activity below the Click activity.

    • Inside the activity, click the Indicate on screen option and select the Ok button. The GIF below shows all the steps you need to follow:


    • Add the expression "This is a UiAutomation example" in the Text field.
    • In the Properties panel, select the check box for the SimulateClick option. This option simulates the click using the technology of the target application and it works in the background.
  7. Drag a Click activity below the Type Into activity.

    • Inside the activity, click the Indicate on screen option and select the File option. The GIF below shows all the steps you need to follow:


    • In the Properties panel, select the check box for the SimulateClick option. This option simulates the click using the technology of the target application, and it works in the background.
  8. Place another Click activity below the Click activity.

    • Inside the activity, click the Indicate on screen option and select the File option. The GIF below shows all the steps you need to follow:


    • In the Properties panel, select the check box for the SimulateClick option. This option simulates the click using the technology of the target application, and it works in the background.
  9. Place a Type Into activity below the Click activity.

    • Inside the activity, click the Indicate on screen option and select the field where the file's name should be introduced. The GIF below shows all the steps you need to follow:


    • Add the expression "This is a UiAutomation example" in the Text field.
    • In the Properties panel, select the check box for the SimulateClick option. This option simulates the click using the technology of the target application and it works in the background.
  10. Place another Click activity below the Type Into activity.

    • Inside the activity, click the Indicate on screen option and select the File option. The GIF below shows all the steps you need to follow:


    • In the Properties panel, select the check box for the SimulateClick option. This option simulates the click using the technology of the target application, and it works in the background.
  11. Drag an Element Exists activity below the Click activity.

    • Inside the activity, click the Indicate on screen option and select the pop-up message. The GIF below shows all the steps you need to follow:


    • In the Properties panel, add the variable FileAlreadyExists in the Exists field.
  12. Place an If activity below the Element Exists activity.

    • Add the variable FileAlreadyExists in the Condition field.
  13. Drag a Click activity inside the Then container.

    • Inside the activity, click the Indicate on screen option and select the File option. The GIF below shows all the steps you need to follow:


    • In the Properties panel, select the check box for the SimulateClick option. This option simulates the click using the technology of the target application, and it works in the background.
  14. Run the process. The automation process opens a new Notepad document, writes some text inside it and saves it as a new file. If a file with the same name is already present, it overwrites it.

Was this page helpful?

Get The Help You Need
Learning RPA - Automation Courses
UiPath Community Forum
Uipath Logo White
Trust and Security
© 2005-2024 UiPath. All rights reserved.