Getting Started Tutorial

Getting Started Tutorial

AppRobotic VM on Amazon Web Services Marketplace

Click here to learn how to subscribe to AppRobotic on AWS Marketplace, launch a virtual machine instance on AWS EC2, and connect to it with RDP.

Click here for another tutorial on how to automate a desktop application with RPA.

Getting Started

Please Note: Copy/pasting the VBScript code below into AppRobotic Designer might require replacement of the formatted quotes in the text below (” “) to plain-text quotes in the Designer to ensure that VBScript can read the code.

If you’re new to AppRobotic then you’re in the right place! Here you will be introduced to the key concepts of AppRobotic, helping you get started with all the Robotic Process Automation (RPA) fundamentals that you need to begin automating Windows applications, including web browsers. This tutorial is intended primarily for beginners that have a basic understanding of VBScript, Python, or JS.

Below, we:
1) Create a simple Hello AppRobotic automation script
2) Automate the Calculator to perform addition and read the result back to the user

To begin, open AppRobotic Designer after downloading and installing from our homepage, or launching an AppRobotic virtual machine instance from the Amazon Web Services Marketplace.

Introduction

A bit of a background:

AppRobotic uses VBScript, Python, and JS as the primary scripting languages for coding automation, which are ready to go out of the box in AppRobotic Designer, but you can use any other scripting or programming language that you like, simply by calling COM or ActiveX object methods. Because of this, if you’re more comfortable using another language such as C# or Java, or would prefer to use another IDE such as Visual Studio or Eclipse, it’s very easy to do so.

And if you’d really like, go ahead and use only Notepad!

On the flip-side, AppRobotic Designer allows you to create powerful and reliable automation quickly and easily by simply browsing and clicking to add the commands you want.

Leveraging the latest in automation technology including Microsoft UI Automation, AppRobotic allows you to “attach” to specific user interface items (“UI Items”) to perform “actions” on them.

For example, you can attach to a specific button on the screen and click it, rather than having to send unreliable X,Y mouse coordinates when using other tools such as macro recorders (although, a macro recorder is also included with AppRobotic, allowing you to record and then run macros in-line within a larger RPA script using the “Play Macro” command, mixing and matching as you please). You can attach to a specific text box and either read text from it, or type text into it.

This allows for very precise automation, even if the location of UI Items such as applications, buttons, text boxes, etc. has changed between automation runs (i.e. screen was resized or the application was moved elsewhere on the screen).

The result is a simple, reliable automation script. Let’s dive into an example.

Tutorial 1: Hello AppRobotic!

In AppRobotic Designer, click “New” on the menu bar to open a new editor page. Paste in the following code:

Set x = CreateObject(“AppRobotic.API”) :

x.Print(“Hello AppRobotic!”) :

Now, click the “Run” button (or Ctrl+R on your keyboard). You will be prompted to save the new script, pick an easy-to-find location such as the Desktop and Save. The above code will now run.

That’s all there is to the basics!

The Print command allows you to “Print” any text to the AppRobotic Printer. Click on “Log Printout” button to view everything you’ve “printed”. This is useful when you don’t want to use many MsgBox/MessageBox commands in your automation scripts, which interrupt execution each time with a pop-up. Printing to the Printer is silent, so you can view everything you printed at the end.

The above is similar to:

Set x = CreateObject(“AppRobotic.API”) :

MsgBox(“Hello AppRobotic!”) :

OK, we executed a basic Hello AppRobotic automation script. From this point, you can continue browsing and adding Actions from the left side of the Designer.

Simply:
~ Select the Action you’d like to add to your script by clicking on it
~ Click one of the two blue arrow buttons between the actions column and the script editor. The top arrow button adds the Action to the line where the cursor is currently located. The bottom arrow button adds the Action to the end of the script.
~ An Action dialog box may appear asking you which UI Item the Action should operate on. You usually specify the UI Item’s Name or ID property, or a variable. The Calculator example on this page demonstrates how to find and use the Name or ID property of a UI Item using the AppRobotic UI Item Explorer tool.

Let’s create another simple RPA bot that’s a bit more useful.

Tutorial 2: Calculator

We’re going to:

~ Launch the Calculator program
~ “Get/Attach” to the Calculator application so commands on UI Items that follow will be performed within it
~ Add 5 + 1
~ Read the addition result into a variable
~ Print result to the AppRobotic Printer as well as display it in a Message Box
~ Close the Calculator application once the user clicks OK on the Message Box

The final code will look like this:

Set x = CreateObject(“AppRobotic.API”) :

x.RunApplication(“C:\Windows\System32\win32calc.exe”) :

x.Wait(3000) : Call x.GetApplication(“Name”, “Calculator”) :

Call x.ButtonClick(“Name”, “5”) :

Call x.ButtonClick(“Name”, “Add”) :

Call x.ButtonClick(“Name”, “1”) : Call x.ButtonClick(“Name”, “Equals”) :

Dim resultText : resultText = x.TextBoxGetText(“ID”, “150”) :

x.Print(“The Result is: ” & resultText) :

x.MessageBox(“The Result is: ” & resultText) :

x.CloseCurrentApplication() :

Here are the detailed steps that will produce the complete code in this example:

1) In AppRobotic Designer, click “New” on the menu bar to open a blank editor page. At this point, it will be pre-filled with:

Set x = CreateObject(“AppRobotic.API”) :

2) On the left-hand side, expand the “Application” Action option, and click on “Run Application” to select it.

3) Click on the top blue Arrow button located in-between the commands and the script editor (you can also simply double-click on an Action to add it).

4) A “Run Application” dialog appears, enter the full path to the application you’re opening (in our case C:\Windows\System32\win32calc.exe), click Insert. The command gets inserted into the line where your cursor is currently located:

x.RunApplication(“C:\Windows\System32\win32calc.exe”) :

5) Next, expand the “Timing” Action option on the left-hand side, and click on “Wait”. Click the bottom blue Arrow button in the middle.

6) Enter ‘3000’ milliseconds without quotes (for 3 seconds), and click Insert. This command pauses the script execution, here we’ll wait 3 seconds in case the Calculator is slow to load.

x.Wait(3000) :

Now that the Calculator is open, we are at the interesting part that allows us to take “action” on specific “UI Items”, which separates AppRobotic from simple macro recorders/players.

7) First, let’s “Get”, or “Attach”, to our Application so future commands that we write will “act” on this application. This saves a lot of time because our code only has to find the application we’re automating in the Windows object hierarchy once, rather than each time we perform an action. To attach to our app, expand “Application”, and select the “Attach to Application” command. Click the bottom green arrow button. A dialog box appears asking you for the Name or ID property value.

To find either the Name or ID, we will use the AppRobotic UI Item Explorer. To open it, click the “UI Item Explorer” button. To find the “Automation ID” or “Name” of an Application, simply click the “Start UIAVerify” button, hover over the Application (usually the top part so you select the main window), and press “Ctrl” on your keyboard. The property values will populate on the right-hand side of Item Explorer. When you do this with the calculator, the Name property value of “Calculator” appears, while the AutomationId property is blank. Returning to the Attach to Application dialog box, select “Name” from the drop-down, enter “Calculator” without quotes into the bottom text field, and click the Insert button.

Call x.GetApplication(“Name”, “Calculator”) :

8) Expand “Common Actions”, and select the “Button Click” command.

9) When you look up the property values for button “5” on the calculator using Item Explorer, the property values of “135” for the AutomationId, and “5” for the Name appear. You can use either value in the Designer. Repeat these steps for the “+”, “1”, “=” buttons, and the TextBox/Label where the Results are displayed. Check to make sure your property values match ours:
~ Button 5: ID: 135 Name: 5
~ Button 1: ID: 131 Name: 1
~ Button +: ID: 93 Name: Add
~ Button =: ID: 121 Name: Equals
~ Label for “Results”: ID: 150 Name: Result

10) Click “Stop Item Explorer” and close the UI Item Explorer application.

11) Returning to the Click Button dialog, select “Name” from the drop-down, and enter “5” without quotes into the bottom text field (Note: You could also select “ID” from the drop-down and enter “135” here instead, you should experiment which results in the UI Item being found faster during script runs). When you click Insert, you’ll see:

Call x.ButtonClick(“Name”, “5”) :

12) Repeat Step 11 for buttons “1”, “+”, and “=”, resulting in:

Call x.ButtonClick(“Name”, “Add”) :
Call x.ButtonClick(“Name”, “1”) :
Call x.ButtonClick(“Name”, “Equals”) :

13) Now, we’ll read the result. Under “Common Actions”, select “TextBox Get Text”, and double-click it to insert into the script.

14) In the drop-down on the Get TextBox Text dialog box select “ID”, and without the quotes type “150”, and something to name the variable where you’d like to store the result value (we chose “resultText”).

Dim resultText : resultText = x.TextBoxGetText(“ID”, “150”) :

15) Next, we’ll output the Result value to a MessageBox and also print it to the AppRobotic Printer (to view output, go to Tools -> Open Printer):

x.MessageBox(“The result is: ” & resultText) :

As you can see, you can switch between VBScript/JS/Python and AppRobotic code wherever you see fit if you’d like to take advantage of the various COM objects and administration scripts already available to VBScript/JS/Python. Now, we’ll switch back to AppRobotic:

x.Print(“The result is: ” & resultText) :

To insert the above command, expand “Debug” on the left-hand side, select “Print to AppRobotic Printer”, click a green arrow button. When the Printer dialog box appears, notice you only have the option to enter specific text. What you enter will be sent to the Printer, so once the command is inserted, just delete the string you typed that appears in quotes, and replace it with the variable name you’re using to store the value of the addition result (resultText). As you can see, you can pass in variables instead of hard-coded values into the commands you’re using. The command dialog boxes allow for a more visual approach to reduce time having to looking up syntax.

16) Once the user running the automation script dismisses/clicks OK on the MessageBox that appears during the script run, we’ll close the Calculator. On the left-hand side, expand “Application” and select “Close Current Application”. We’re using the “Current” command, rather than the “Close Application” command because we already Attached to it earlier in our script. We could, of course, use the other command as well to either close the Calculator or any other running app by locating it using its Name or ID property. Click Insert, and the final command is inserted into your script:

x.CloseCurrentApplication() :

17) Click the Run button to save and run the script. Everything should run automatically, you’ll only have to click OK on the MessageBox.

Conclusion

Overall, automating with AppRobotic breaks down to these general steps:
1) Open Windows Application or Website you’d like to automate
2) Look up a UI Item’s (button, text box) Name or ID property using the AppRobotic UI Item Explorer tool
3) Look up the UI Item’s ControlType (to make sure you’re not trying to use a Click action on a Label type thinking it’s a Button, for example)
4) Perform an Action on the UI Item (click, select, set text, get text, type, etc…)
5) Repeat steps 2-4 for every UI Item on which you need to perform an Action
6) Optional. Output results to Excel, SQL/MySQL DB, online/network storage, or simply Print to AppRobotic Printer for immediate review
7) Optional. Loop through steps 1-6 when performing same steps on multiple records in an input file (Excel or SQL database, for example)

Explore more in-depth tutorials on our Robotic Process Automation University!

Enjoy and happy automating!