# Example of Recording Actions While Working with Calculator

Suppose that before working with the Calculator, the robot needs to first launch the Calculator. Click the "Launch Program" button and review the options.

<figure><img src="https://3199517203-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4mXXYsqBuhj7RyX6Y4Yw%2Fuploads%2Fgit-blob-84a189ba3a8c976743e2a24a4dffbeecc26b9499%2F%D0%9E%D1%81%D0%BD%D0%9C%D0%B5%D0%BD%D1%8E%D0%97%D0%B0%D0%BF%D0%B8%D1%81%D0%97%D0%B0%D0%BF%D0%B8%D1%815%D0%94%D0%B8%D0%B0%D0%BB%D0%BE%D0%B3%D0%9E%D0%BA%D0%BD%D0%BE.png?alt=media" alt=""><figcaption></figcaption></figure>

When you click the "Select Window" button, the window of the required program is simply highlighted. Press the CTRL button.

<figure><img src="https://3199517203-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4mXXYsqBuhj7RyX6Y4Yw%2Fuploads%2Fgit-blob-fd51ac407c0060f051097919f54057897a012276%2F2024-04-11_19-07-33.png?alt=media" alt=""><figcaption></figcaption></figure>

The robot has found the path to the application itself. If desired, you can add launch parameters (command line parameters). You can specify that the robot should wait for the launch for a certain amount of time. When you click the "Save" button, the program launch block is added to the diagram.

When you click the "Select Process" button, you can choose a process from the list of currently running processes.

<figure><img src="https://3199517203-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4mXXYsqBuhj7RyX6Y4Yw%2Fuploads%2Fgit-blob-de768a4ac6837471f60b33cfeac391597369696c%2F%D0%92%D1%8B%D0%B1%D1%80%D0%9F%D1%80%D0%BE%D1%86%D0%B5%D1%81%D1%81.png?alt=media" alt=""><figcaption></figcaption></figure>

The third option is to select the desired exe file from the file explorer.

Selecting a window is usually the most convenient method.

A "Launch Application" block has appeared in the diagram, configured to launch the corresponding application.

<figure><img src="https://3199517203-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4mXXYsqBuhj7RyX6Y4Yw%2Fuploads%2Fgit-blob-c282b496fc5e6d07a79e23a6607cee7c08450869%2F%D1%80%D0%B0%D1%81%D0%BF%D0%B7%D0%BD%20%D0%B8%20%D0%B7%D0%B0%D0%BF%D1%83%D1%81%D1%82%D0%B8%D1%82%D1%8C.png?alt=media" alt=""><figcaption></figcaption></figure>

Note that the robot can handle complex cases. For example, the calculator in Windows 10 is not a real application; it is launched through a helper mechanism and cannot be started via the command line. Therefore, the robot finds the correct path for this application:

![](https://sherparpa.ru/wp-content/uploads/2023/11/image55-413w265h.png)

Next, in the action recording palette:

You can hover the cursor over a control element for a certain amount of time, perform single and double clicks, click on a specified image on the screen, or click on an image inside a window or control element. The same logic applies here as with text recognition from the screen, except that in this case, a visual representation of a certain element on the screen is simply being searched for. For example, you need to find the calculator button just by its appearance, not by its selector or the text on it. Click on the "Click on a specified image inside a window or control element" tool. Next, you need to highlight the desired control element and press CTRL.

We simply highlight the calculator window so that the robot does not search for the required image across the entire screen.

<figure><img src="https://3199517203-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4mXXYsqBuhj7RyX6Y4Yw%2Fuploads%2Fgit-blob-c3df4d013239c582fbe475e5ab5b84434e20f618%2F%D0%BA%D0%B0%D0%BB%D1%8C%D0%BA%D1%83%D0%BB%D1%8F%D1%82%D0%BE%D1%80.png?alt=media" alt="" width="441"><figcaption></figcaption></figure>

Press CTRL and then select a sample of the image you will be searching for.

![](https://sherparpa.ru/wp-content/uploads/2023/11/image42-309w258h.png)

Next, you need to specify a point inside or outside the found image where the click will actually occur. That is, the found image can be used as an anchor, and you can click on another point in the window relative to this anchor. Let's click in the center. The action has been recorded and can be executed later.

![](https://sherparpa.ru/wp-content/uploads/2023/11/image24-180w77h.png)

When you work with blocks that somehow record an image, the properties in which these images are stored look like a unique set of characters (identifier):

![](https://sherparpa.ru/wp-content/uploads/2023/11/image28-450w214h.png)

Under this name, the robot saves images with sample images in the Images folder within your project (such a folder exists in every project).

When you click the "Publish" button, not only the diagram is published into a single archive, but also all images from the Images folder. This means that the robot with all its resources can then be transferred as a single file with the .robot extension to another computer and run there without any problems.

The wait function for an element to appear on the screen can be very useful. Sometimes it may be necessary to delay the robot's work until we wait for a certain window to disappear from the screen or a certain element to appear on the screen. Click on this tool

![](https://sherparpa.ru/wp-content/uploads/2023/11/image29-98w36h.png)

And as usual, point to the required control element, relative to which the robot's work will be delayed.

![](https://sherparpa.ru/wp-content/uploads/2023/11/image31-349w298h.png)

Press CTRL to record the action. Check the properties of the block added to the diagram.

You can set a maximum wait time in seconds. The robot will continue executing the scenario after this block either when the specified control element appears on the screen according to the selector or when the wait time expires.

![](https://sherparpa.ru/wp-content/uploads/2023/11/image33-465w304h.png)

If the wait time has expired but the element has not yet appeared, there is an option to connect a block on the right via the "If Error" connector, and if it is connected, in case the element does not appear on the screen, the scenario will proceed not downwards but to the right. If the "If Error" connector is not connected, the scenario will go down in any case.

The "Elapsed Time" property is a numeric type variable that records the number of seconds that have actually passed until this element appeared. For example, if the maximum wait time specified is 10 minutes, and the element appeared after 5 minutes, the variable PassedTime will record the number 5.

The "Highlight Element" block is useful when creating interactive training guides. There is a block that allows you to capture and drag elements, blocks that allow you to perform certain actions in browsers, such as refreshing pages, clicking the Back button. You can not only launch a browser with a specified tab but also connect to a browser and its tab that is already on the screen.

Let’s remember that when clicking on a control element that is off-screen, in all cases, the robot will try to automatically scroll some page or list in the application to the specified element if it is not in view.

There is another interesting point related to mouse clicks in browser automation: as a rule, in all blocks that work with programs and browsers, there is a property called "Process ID". It contains the variable ProcessID, which is a pointer variable to the specific program we are currently working with. This is important because two Word applications can be open simultaneously, each with two documents. You can transfer something from document to document. That is, when you set a block to work with Word or Excel or some other program, you need to specify which specific application, i.e., which specific instance of the application we are currently using.

The same happens with browsers. You can open Chrome or Explorer and have several tabs in it. You may need to switch between tabs. Therefore, the ProcessID variable contains information about which specific instance of the application we are currently working with, as well as (if it is a browser) which tab of this browser we are currently working with.

Where does the value of this variable come from? It appears in the "Launch Application" block. In the "Click Mouse" block, the Process ID is an input property that defines the operation of the block. In the "Launch Application" block, the Process ID is an output property, meaning that the block will write the required value to this variable after launching the application.
